From 437ea72cb37acc0b094799eef1bd5ddd207bce22 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Thu, 5 Dec 2024 18:04:45 +0100 Subject: [PATCH] undo some changes --- cipher.go | 8 ++++---- rc4.go | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cipher.go b/cipher.go index 6f6b56bc..f2e1fece 100644 --- a/cipher.go +++ b/cipher.go @@ -178,7 +178,7 @@ func (c *evpCipher) encrypt(dst, src []byte) error { } defer ossl.EVP_CIPHER_CTX_free(enc_ctx) - if ossl.EVP_EncryptUpdate_wrapper(enc_ctx, unsafe.SliceData(dst), unsafe.SliceData(src), int32(c.blockSize)) != nil { + if ossl.EVP_EncryptUpdate_wrapper(enc_ctx, base(dst), base(src), int32(c.blockSize)) != nil { return errors.New("EncryptUpdate failed") } runtime.KeepAlive(c) @@ -207,7 +207,7 @@ func (c *evpCipher) decrypt(dst, src []byte) error { return errors.New("could not disable cipher padding") } - ossl.EVP_DecryptUpdate_wrapper(dec_ctx, unsafe.SliceData(dst), unsafe.SliceData(src), int32(c.blockSize)) + ossl.EVP_DecryptUpdate_wrapper(dec_ctx, base(dst), base(src), int32(c.blockSize)) runtime.KeepAlive(c) return nil } @@ -234,7 +234,7 @@ func (x *cipherCBC) CryptBlocks(dst, src []byte) { panic("crypto/cipher: output smaller than input") } if len(src) > 0 { - if ossl.EVP_CipherUpdate_wrapper(x.ctx, unsafe.SliceData(dst), unsafe.SliceData(src), int32(len(src))) != nil { + if ossl.EVP_CipherUpdate_wrapper(x.ctx, base(dst), base(src), int32(len(src))) != nil { panic("crypto/cipher: CipherUpdate failed") } runtime.KeepAlive(x) @@ -245,7 +245,7 @@ func (x *cipherCBC) SetIV(iv []byte) { if len(iv) != x.blockSize { panic("cipher: incorrect length IV") } - if ossl.EVP_CipherInit_ex(x.ctx, nil, nil, nil, unsafe.SliceData(iv), int32(cipherOpNone)) != nil { + if ossl.EVP_CipherInit_ex(x.ctx, nil, nil, nil, base(iv), int32(cipherOpNone)) != nil { panic("cipher: unable to initialize EVP cipher ctx") } } diff --git a/rc4.go b/rc4.go index e75bc553..18fe5038 100644 --- a/rc4.go +++ b/rc4.go @@ -4,7 +4,6 @@ package openssl import ( "runtime" - "unsafe" "github.com/golang-fips/openssl/v2/internal/ossl" ) @@ -59,7 +58,7 @@ func (c *RC4Cipher) XORKeyStream(dst, src []byte) { // which is what crypto/rc4 does. _ = dst[len(src)-1] var outLen int32 - if err := ossl.EVP_EncryptUpdate(c.ctx, unsafe.SliceData(dst), &outLen, unsafe.SliceData(src), int32(len(src))); err != nil { + if err := ossl.EVP_EncryptUpdate(c.ctx, base(dst), &outLen, base(src), int32(len(src))); err != nil { panic(err) } if int(outLen) != len(src) {