Skip to content

Commit

Permalink
undo some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Dec 5, 2024
1 parent cc1778e commit 437ea72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cipher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand All @@ -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")
}
}
Expand Down
3 changes: 1 addition & 2 deletions rc4.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package openssl

import (
"runtime"
"unsafe"

"github.com/golang-fips/openssl/v2/internal/ossl"
)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 437ea72

Please sign in to comment.