Documentation
¶
Overview ¶
Package cryptox holds the cryptographic primitives the Iranian PSPs ask for: 3DES-ECB signatures (Sadad), AES-CBC plus RSA envelopes (IranKish) and RSA signatures over the request body (Pasargad).
Everything is built on the standard library.
Index ¶
- func AESCBCEncrypt(key, iv, data []byte) ([]byte, error)
- func EncryptPKCS1v15(pub *rsa.PublicKey, data []byte) ([]byte, error)
- func PKCS7Pad(data []byte, blockSize int) []byte
- func ParseRSAPrivateKey(key string) (*rsa.PrivateKey, error)
- func ParseRSAPublicKey(key string) (*rsa.PublicKey, error)
- func RandomBytes(n int) ([]byte, error)
- func SHA256Sum(data []byte) []byte
- func SignPKCS1v15SHA1(priv *rsa.PrivateKey, data []byte) (string, error)
- func SignPKCS1v15SHA256(priv *rsa.PrivateKey, data []byte) (string, error)
- func TripleDESEncryptECB(data []byte, keyBase64 string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESCBCEncrypt ¶
AESCBCEncrypt encrypts data with AES-CBC and PKCS#7 padding.
func EncryptPKCS1v15 ¶
EncryptPKCS1v15 encrypts data with the given RSA public key.
func ParseRSAPrivateKey ¶
func ParseRSAPrivateKey(key string) (*rsa.PrivateKey, error)
ParseRSAPrivateKey accepts a PEM encoded PKCS#1 or PKCS#8 private key, the bare base64 body of one, or a .NET style <RSAKeyValue> XML key, which is the format Pasargad still distributes.
func ParseRSAPublicKey ¶
ParseRSAPublicKey accepts a PEM encoded PKIX or PKCS#1 public key, or the bare base64 body of one, and returns the RSA key.
func RandomBytes ¶
RandomBytes returns n cryptographically secure random bytes.
func SignPKCS1v15SHA1 ¶
func SignPKCS1v15SHA1(priv *rsa.PrivateKey, data []byte) (string, error)
SignPKCS1v15SHA1 signs data with RSASSA-PKCS1-v1_5 over SHA-1 and returns the base64 signature. Pasargad's "Sign" header uses this legacy combination.
func SignPKCS1v15SHA256 ¶
func SignPKCS1v15SHA256(priv *rsa.PrivateKey, data []byte) (string, error)
SignPKCS1v15SHA256 signs data with RSASSA-PKCS1-v1_5 over SHA-256 and returns the base64 signature.
Types ¶
This section is empty.