60 lines
1.6 KiB
Go
60 lines
1.6 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 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 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 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 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 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)
|
|
}
|