Documentation ¶
Index ¶
- Variables
- func AESCBCDecrypt(ciphertext, key, iv []byte, padding Padding) ([]byte, error)
- func AESCBCDecryptWithSalt(data, key []byte, iter int, magic string, padding Padding, h func() hash.Hash) ([]byte, error)
- func AESCBCEncrypt(plaintext, key, iv []byte, padding Padding) ([]byte, error)
- func AESCBCEncryptWithSalt(plaintext, key []byte, iter int, magic string, padding Padding, ...) ([]byte, error)
- func AESCFBDecrypt(ciphertext, key, iv []byte, padding Padding) ([]byte, error)
- func AESCFBEncrypt(plaintext, key, iv []byte, padding Padding) ([]byte, error)
- func AESDecryptWithSalt(ciphertext, key []byte, iterCount int, magic string, h func() hash.Hash, ...) ([]byte, error)
- func AESECBDecrypt(ciphertext, key []byte, padding Padding) ([]byte, error)
- func AESECBEncrypt(plaintext, key []byte, padding Padding) ([]byte, error)
- func AESEncryptWithSalt(plaintext, key []byte, iter int, magic string, h func() hash.Hash, ...) ([]byte, error)
- func AESGCMDecrypt(ciphertext, key, additional []byte) ([]byte, error)
- func AESGCMDecryptWithNonce(ciphertext, key, nonce, additional []byte) ([]byte, error)
- func AESGCMEncrypt(plaintext, key, additional []byte) ([]byte, error)
- func AESGCMEncryptWithNonce(plaintext, key, nonce, additional []byte) ([]byte, error)
- func DecodeCertificate(data []byte) (*x509.Certificate, error)
- func GenerateRSAKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func HmacMD5(data, key []byte) []byte
- func HmacSHA1(data, key []byte) []byte
- func HmacSHA256(data, key []byte) []byte
- func HmacSHA512(data, key []byte) []byte
- func MD5(value []byte) []byte
- func RSADecrypt(ciphertext []byte, key *rsa.PrivateKey) ([]byte, error)
- func RSAEncrypt(plaintext []byte, key *rsa.PublicKey) ([]byte, error)
- func RSASignPKCS1v15(plaintext []byte, key *rsa.PrivateKey, hash crypto.Hash) ([]byte, error)
- func RSAVerifyPKCS1v15(ciphertext, signature []byte, key *rsa.PublicKey, hash crypto.Hash) error
- func RandBytes(length int) (data []byte, err error)
- func SHA1(value []byte) []byte
- func SHA256(value []byte) []byte
- func SHA512(value []byte) []byte
- type NoPadding
- type PKCS1PrivateKey
- type PKCS1PublicKey
- type PKCS5Padding
- type PKCS7Padding
- type PKCS8PrivateKey
- type PKIXPublicKey
- type Padding
- type PrivateKey
- type PrivateKeyDecoder
- type PrivateKeyEncoder
- type PublicKey
- type PublicKeyDecoder
- type PublicKeyEncoder
- type ZeroPadding
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrInvalidPadding = errors.New("invalid padding")
)
Functions ¶
func AESCBCDecrypt ¶
func AESCBCDecryptWithSalt ¶
func AESCBCEncrypt ¶
AESCBCEncrypt 由key的长度决定是128, 192 还是 256
func AESCBCEncryptWithSalt ¶
func AESCFBDecrypt ¶
func AESDecryptWithSalt ¶
func AESEncryptWithSalt ¶
func AESGCMDecrypt ¶
func AESGCMDecryptWithNonce ¶
func AESGCMEncrypt ¶
func AESGCMEncryptWithNonce ¶
func DecodeCertificate ¶
func DecodeCertificate(data []byte) (*x509.Certificate, error)
func GenerateRSAKeyPair ¶
func HmacSHA256 ¶
func HmacSHA512 ¶
func RSADecrypt ¶
func RSADecrypt(ciphertext []byte, key *rsa.PrivateKey) ([]byte, error)
RSADecrypt 使用私钥 key 对数据 ciphertext 进行解密
func RSAEncrypt ¶
RSAEncrypt 使用公钥 key 对数据 plaintext 进行加密
func RSASignPKCS1v15 ¶
func RSAVerifyPKCS1v15 ¶
Types ¶
type PKCS1PrivateKey ¶
type PKCS1PrivateKey struct {
// contains filtered or unexported fields
}
func (PKCS1PrivateKey) RSAPrivateKey ¶
func (p PKCS1PrivateKey) RSAPrivateKey() (*rsa.PrivateKey, error)
type PKCS1PublicKey ¶
type PKCS1PublicKey struct {
// contains filtered or unexported fields
}
func (PKCS1PublicKey) RSAPublicKey ¶
func (p PKCS1PublicKey) RSAPublicKey() (*rsa.PublicKey, error)
type PKCS5Padding ¶
type PKCS5Padding struct {
// contains filtered or unexported fields
}
type PKCS7Padding ¶
type PKCS7Padding struct {
// contains filtered or unexported fields
}
type PKCS8PrivateKey ¶
type PKCS8PrivateKey struct {
// contains filtered or unexported fields
}
func (PKCS8PrivateKey) ECDSAPrivateKey ¶
func (p PKCS8PrivateKey) ECDSAPrivateKey() (*ecdsa.PrivateKey, error)
func (PKCS8PrivateKey) ED25519PrivateKey ¶
func (p PKCS8PrivateKey) ED25519PrivateKey() (*ed25519.PrivateKey, error)
func (PKCS8PrivateKey) PrivateKey ¶
func (p PKCS8PrivateKey) PrivateKey() (any, error)
func (PKCS8PrivateKey) RSAPrivateKey ¶
func (p PKCS8PrivateKey) RSAPrivateKey() (*rsa.PrivateKey, error)
type PKIXPublicKey ¶
type PKIXPublicKey struct {
// contains filtered or unexported fields
}
func (PKIXPublicKey) ECDSAPublicKey ¶
func (p PKIXPublicKey) ECDSAPublicKey() (*ecdsa.PublicKey, error)
func (PKIXPublicKey) ED25519PublicKey ¶
func (p PKIXPublicKey) ED25519PublicKey() (*ed25519.PublicKey, error)
func (PKIXPublicKey) PublicKey ¶
func (p PKIXPublicKey) PublicKey() (any, error)
func (PKIXPublicKey) RSAPublicKey ¶
func (p PKIXPublicKey) RSAPublicKey() (*rsa.PublicKey, error)
type PrivateKey ¶
type PrivateKey interface { Public() crypto.PublicKey Equal(crypto.PrivateKey) bool }
type PrivateKeyDecoder ¶
type PrivateKeyDecoder []byte
func DecodePrivateKey ¶
func DecodePrivateKey(data []byte) PrivateKeyDecoder
func (PrivateKeyDecoder) PKCS1 ¶
func (p PrivateKeyDecoder) PKCS1() PKCS1PrivateKey
func (PrivateKeyDecoder) PKCS8 ¶
func (p PrivateKeyDecoder) PKCS8() PKCS8PrivateKey
type PrivateKeyEncoder ¶
type PrivateKeyEncoder struct {
// contains filtered or unexported fields
}
func EncodePrivateKey ¶
func EncodePrivateKey(key PrivateKey) PrivateKeyEncoder
func (PrivateKeyEncoder) PKCS1 ¶
func (p PrivateKeyEncoder) PKCS1() ([]byte, error)
func (PrivateKeyEncoder) PKCS8 ¶
func (p PrivateKeyEncoder) PKCS8() ([]byte, error)
type PublicKeyDecoder ¶
type PublicKeyDecoder []byte
func DecodePublicKey ¶
func DecodePublicKey(data []byte) PublicKeyDecoder
func (PublicKeyDecoder) PKCS1 ¶
func (p PublicKeyDecoder) PKCS1() PKCS1PublicKey
func (PublicKeyDecoder) PKIX ¶
func (p PublicKeyDecoder) PKIX() PKIXPublicKey
type PublicKeyEncoder ¶
type PublicKeyEncoder struct {
// contains filtered or unexported fields
}
func EncodePublicKey ¶
func EncodePublicKey(key PublicKey) PublicKeyEncoder
func (PublicKeyEncoder) PKCS1 ¶
func (p PublicKeyEncoder) PKCS1() ([]byte, error)
func (PublicKeyEncoder) PKIX ¶
func (p PublicKeyEncoder) PKIX() ([]byte, error)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
|
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0. |
Package pkcs12 implements some of PKCS#12.
|
Package pkcs12 implements some of PKCS#12. |
internal/rc2
Package rc2 implements the RC2 cipher
|
Package rc2 implements the RC2 cipher |
Click to show internal directories.
Click to hide internal directories.