Documentation ¶
Index ¶
- Constants
- func GetHashFunc(hash string) func() hash.Hash
- func NewAESGCMAEAD(key types.Key, randomService services.CPRNGService) (types.AEAD, error)
- func NewRSASSAPKCS1SHA(hashFunc func() hash.Hash, hashID crypto.Hash, ...) (types.Unwrapping, error)
- func NewXChaCha20Poly1305AEAD(key types.Key, randomService services.CPRNGService) (types.AEAD, error)
- func ValidateAESKeySize(sizeInBytes uint32) error
- type AESGCMAEAD
- type RSASSAPKCS1SHA
- type XChaCha20Poly1305AEAD
Constants ¶
const ( // AESGCMIVSize is the acceptable IV size defined by RFC 5116. AESGCMIVSize = 12 // AESGCMTagSize is the acceptable tag size defined by RFC 5116. AESGCMTagSize = 16 )
Variables ¶
This section is empty.
Functions ¶
func GetHashFunc ¶
GetHashFunc returns the corresponding hash function of the given hash name.
func NewAESGCMAEAD ¶
NewAESGCMAEAD NewAESGCM returns an AESGCMAEAD instance, where key is the AES key with length 16 bytes (AES-128) or 32 bytes (AES-256).
func NewRSASSAPKCS1SHA ¶
func NewRSASSAPKCS1SHA(hashFunc func() hash.Hash, hashID crypto.Hash, randomService services.CPRNGService) (types.Unwrapping, error)
NewRSASSAPKCS1SHA returns an RSASSAPKCS1SHA instance
func NewXChaCha20Poly1305AEAD ¶
func NewXChaCha20Poly1305AEAD(key types.Key, randomService services.CPRNGService) (types.AEAD, error)
NewXChaCha20Poly1305AEAD returns an XChaCha20Poly1305AEAD instance. The key argument should be a 32-bytes key.
func ValidateAESKeySize ¶
ValidateAESKeySize checks if the given key size is a valid AES key size.
Types ¶
type AESGCMAEAD ¶
type AESGCMAEAD struct {
// contains filtered or unexported fields
}
AESGCMAEAD is an implementation of AEAD interface.
func (*AESGCMAEAD) Decrypt ¶
func (a *AESGCMAEAD) Decrypt(ciphertext, associatedData []byte) ([]byte, error)
Decrypt decrypts ciphertext with iv as the initialization vector and associatedData as associated data.
If prependIV is true, the iv argument and the first AESGCMIVSize bytes of ciphertext must be equal. The ciphertext argument is as follows:
| iv | actual ciphertext | tag |
If false, the ciphertext argument is as follows:
| actual ciphertext | tag |
func (*AESGCMAEAD) Encrypt ¶
func (a *AESGCMAEAD) Encrypt(plaintext, associatedData []byte) ([]byte, error)
Encrypt encrypts plaintext with iv as the initialization vector and associatedData as associated data.
If prependIV is true, the returned ciphertext contains both the IV used for encryption and the actual ciphertext. If false, the returned ciphertext contains only the actual ciphertext.
Note: The crypto library's AES-GCM implementation always returns the ciphertext with an AESGCMTagSize (16-byte) tag.
type RSASSAPKCS1SHA ¶
type RSASSAPKCS1SHA struct {
// contains filtered or unexported fields
}
RSASSAPKCS1SHA is an implementation of AEAD interface.
type XChaCha20Poly1305AEAD ¶
type XChaCha20Poly1305AEAD struct {
// contains filtered or unexported fields
}
XChaCha20Poly1305AEAD is an implementation of AEAD interface.