init: v1.0.0
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package rsa
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
|
||||
"xdx.jelly/xgcl/rsa/internal"
|
||||
"xdx.jelly/xgcl/sm"
|
||||
)
|
||||
|
||||
var VerifyPKCS1v15 = internal.VerifyPKCS1v15
|
||||
var SignPKCS1v15 = internal.SignPKCS1v15
|
||||
|
||||
// helper function for RSA_SM3 signature
|
||||
|
||||
// SignPKCS1v15WithSm3 signature with SM3
|
||||
func SignPKCS1v15WithSm3(priv *PrivateKey, hashed []byte) ([]byte, error) {
|
||||
return SignPKCS1v15(nil, priv, sm.SM3, hashed)
|
||||
}
|
||||
|
||||
// SignPKCS1v15WithSm3 signature with SHA256
|
||||
func SignPKCS1v15WithSha256(priv *PrivateKey, hashed []byte) ([]byte, error) {
|
||||
return SignPKCS1v15(nil, priv, sm.SHA256, hashed)
|
||||
}
|
||||
|
||||
// VerifyPKCS1v15WithSm3 verify with SM3
|
||||
func VerifyPKCS1v15WithSm3(pub *PublicKey, hashed []byte, sig []byte) error {
|
||||
return VerifyPKCS1v15(pub, sm.SM3, hashed, sig)
|
||||
}
|
||||
|
||||
// VerifyPKCS1v15WithSha256 verify with SHA256
|
||||
func VerifyPKCS1v15WithSha256(pub *PublicKey, hashed []byte, sig []byte) error {
|
||||
return VerifyPKCS1v15(pub, sm.SHA256, hashed, sig)
|
||||
}
|
||||
|
||||
// PKCS1v15 implement the sdf.RSAAdapter interface
|
||||
type PKCS1v15 struct{}
|
||||
|
||||
// 0018用的是PKCS1v1.5 还有其他暂不实现
|
||||
func NewPKCS1v15() PKCS1v15 {
|
||||
return PKCS1v15{}
|
||||
}
|
||||
|
||||
func (PKCS1v15) Sign(priv *PrivateKey, hash crypto.Hash, hashed []byte) ([]byte, error) {
|
||||
return internal.SignPKCS1v15(nil, priv, sm.Hash{Hash: hash}, hashed)
|
||||
}
|
||||
|
||||
func (PKCS1v15) Verify(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte) error {
|
||||
return internal.VerifyPKCS1v15(pub, sm.Hash{Hash: hash}, hashed, sig)
|
||||
}
|
||||
Reference in New Issue
Block a user