mirror of
https://github.com/libp2p/go-openssl.git
synced 2024-12-26 23:40:07 +08:00
space monkey internal commit export
[katamari commit: 40d84e93b0bf20707c02cdbdaec154a0d387043d]
This commit is contained in:
parent
791cc52ff2
commit
a7000f8add
26
ciphers.go
26
ciphers.go
@ -58,11 +58,11 @@ type cipherCtx struct {
|
||||
}
|
||||
|
||||
type encryptionCipherCtx struct {
|
||||
cipherCtx
|
||||
*cipherCtx
|
||||
}
|
||||
|
||||
type decryptionCipherCtx struct {
|
||||
cipherCtx
|
||||
*cipherCtx
|
||||
}
|
||||
|
||||
type CipherCtx interface {
|
||||
@ -149,23 +149,23 @@ func GetCipherByNid(nid int) (*Cipher, error) {
|
||||
return GetCipherByName(sn)
|
||||
}
|
||||
|
||||
func (c Cipher) Nid() int {
|
||||
func (c *Cipher) Nid() int {
|
||||
return int(C.EVP_CIPHER_nid_not_a_macro(c.ptr))
|
||||
}
|
||||
|
||||
func (c Cipher) ShortName() (string, error) {
|
||||
func (c *Cipher) ShortName() (string, error) {
|
||||
return Nid2ShortName(c.Nid())
|
||||
}
|
||||
|
||||
func (c Cipher) BlockSize() int {
|
||||
func (c *Cipher) BlockSize() int {
|
||||
return int(C.EVP_CIPHER_block_size_not_a_macro(c.ptr))
|
||||
}
|
||||
|
||||
func (c Cipher) KeySize() int {
|
||||
func (c *Cipher) KeySize() int {
|
||||
return int(C.EVP_CIPHER_key_length_not_a_macro(c.ptr))
|
||||
}
|
||||
|
||||
func (c Cipher) IVSize() int {
|
||||
func (c *Cipher) IVSize() int {
|
||||
return int(C.EVP_CIPHER_iv_length_not_a_macro(c.ptr))
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ func newEncryptionCipherCtx(c *Cipher, e *Engine, key, iv []byte) (
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &encryptionCipherCtx{*ctx}, nil
|
||||
return &encryptionCipherCtx{cipherCtx: ctx}, nil
|
||||
}
|
||||
|
||||
func newDecryptionCipherCtx(c *Cipher, e *Engine, key, iv []byte) (
|
||||
@ -248,7 +248,7 @@ func newDecryptionCipherCtx(c *Cipher, e *Engine, key, iv []byte) (
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &decryptionCipherCtx{*ctx}, nil
|
||||
return &decryptionCipherCtx{cipherCtx: ctx}, nil
|
||||
}
|
||||
|
||||
func NewEncryptionCipherCtx(c *Cipher, e *Engine, key, iv []byte) (
|
||||
@ -361,11 +361,11 @@ func (ctx *decryptionCipherCtx) DecryptFinal() ([]byte, error) {
|
||||
}
|
||||
|
||||
type authEncryptionCipherCtx struct {
|
||||
encryptionCipherCtx
|
||||
*encryptionCipherCtx
|
||||
}
|
||||
|
||||
type authDecryptionCipherCtx struct {
|
||||
decryptionCipherCtx
|
||||
*decryptionCipherCtx
|
||||
}
|
||||
|
||||
func getGCMCipher(blocksize int) (*Cipher, error) {
|
||||
@ -404,7 +404,7 @@ func NewGCMEncryptionCipherCtx(blocksize int, e *Engine, key, iv []byte) (
|
||||
return nil, errors.New("failed to apply IV")
|
||||
}
|
||||
}
|
||||
return &authEncryptionCipherCtx{*ctx}, nil
|
||||
return &authEncryptionCipherCtx{encryptionCipherCtx: ctx}, nil
|
||||
}
|
||||
|
||||
func NewGCMDecryptionCipherCtx(blocksize int, e *Engine, key, iv []byte) (
|
||||
@ -428,7 +428,7 @@ func NewGCMDecryptionCipherCtx(blocksize int, e *Engine, key, iv []byte) (
|
||||
return nil, errors.New("failed to apply IV")
|
||||
}
|
||||
}
|
||||
return &authDecryptionCipherCtx{*ctx}, nil
|
||||
return &authDecryptionCipherCtx{decryptionCipherCtx: ctx}, nil
|
||||
}
|
||||
|
||||
func (ctx *authEncryptionCipherCtx) ExtraData(aad []byte) error {
|
||||
|
Loading…
Reference in New Issue
Block a user