starcrypto/rsa.go

96 lines
3.1 KiB
Go

package starcrypto
import (
"b612.me/starcrypto/asymm"
"crypto"
"crypto/rsa"
)
func GenerateRsaKey(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error) {
return asymm.GenerateRsaKey(bits)
}
func EncodeRsaPrivateKey(private *rsa.PrivateKey, secret string) ([]byte, error) {
return asymm.EncodeRsaPrivateKey(private, secret)
}
func EncodeRsaPrivateKeyWithLegacy(private *rsa.PrivateKey, secret string, legacy bool) ([]byte, error) {
return asymm.EncodeRsaPrivateKeyWithLegacy(private, secret, legacy)
}
func EncodeRsaPrivateKeyPKCS8(private *rsa.PrivateKey, secret string) ([]byte, error) {
return asymm.EncodeRsaPrivateKeyPKCS8(private, secret)
}
func EncodeRsaPublicKey(public *rsa.PublicKey) ([]byte, error) {
return asymm.EncodeRsaPublicKey(public)
}
func DecodeRsaPrivateKey(private []byte, password string) (*rsa.PrivateKey, error) {
return asymm.DecodeRsaPrivateKey(private, password)
}
func DecodeRsaPrivateKeyWithLegacy(private []byte, password string, legacy bool) (*rsa.PrivateKey, error) {
return asymm.DecodeRsaPrivateKeyWithLegacy(private, password, legacy)
}
func DecodeRsaPrivateKeyPKCS8(private []byte, password string) (*rsa.PrivateKey, error) {
return asymm.DecodeRsaPrivateKeyPKCS8(private, password)
}
func DecodeRsaPublicKey(pubStr []byte) (*rsa.PublicKey, error) {
return asymm.DecodeRsaPublicKey(pubStr)
}
func EncodeRsaSSHPublicKey(public *rsa.PublicKey) ([]byte, error) {
return asymm.EncodeRsaSSHPublicKey(public)
}
func GenerateRsaSSHKeyPair(bits int, secret string) (string, string, error) {
return asymm.GenerateRsaSSHKeyPair(bits, secret)
}
func GenerateRsaSSHKeyPairWithLegacy(bits int, secret string, legacy bool) (string, string, error) {
return asymm.GenerateRsaSSHKeyPairWithLegacy(bits, secret, legacy)
}
func RSAEncrypt(pub *rsa.PublicKey, data []byte) ([]byte, error) {
return asymm.RSAEncrypt(pub, data)
}
func RSADecrypt(prikey *rsa.PrivateKey, data []byte) ([]byte, error) {
return asymm.RSADecrypt(prikey, data)
}
func RSAEncryptOAEP(pub *rsa.PublicKey, data, label []byte, hashType crypto.Hash) ([]byte, error) {
return asymm.RSAEncryptOAEP(pub, data, label, hashType)
}
func RSADecryptOAEP(prikey *rsa.PrivateKey, data, label []byte, hashType crypto.Hash) ([]byte, error) {
return asymm.RSADecryptOAEP(prikey, data, label, hashType)
}
func RSASign(msg, priKey []byte, password string, hashType crypto.Hash) ([]byte, error) {
return asymm.RSASign(msg, priKey, password, hashType)
}
func RSAVerify(data, msg, pubKey []byte, hashType crypto.Hash) error {
return asymm.RSAVerify(data, msg, pubKey, hashType)
}
func RSASignPSS(msg, priKey []byte, password string, hashType crypto.Hash, opts *rsa.PSSOptions) ([]byte, error) {
return asymm.RSASignPSS(msg, priKey, password, hashType, opts)
}
func RSAVerifyPSS(sig, msg, pubKey []byte, hashType crypto.Hash, opts *rsa.PSSOptions) error {
return asymm.RSAVerifyPSS(sig, msg, pubKey, hashType, opts)
}
func RSAEncryptByPrivkey(privt *rsa.PrivateKey, data []byte) ([]byte, error) {
return asymm.RSAEncryptByPrivkey(privt, data)
}
func RSADecryptByPubkey(pub *rsa.PublicKey, data []byte) ([]byte, error) {
return asymm.RSADecryptByPubkey(pub, data)
}