Commit c2dcc5cc authored by Ramesh V Rayaprolu's avatar Ramesh V Rayaprolu Committed by Jeff Wendling

avoid panic while encrypting empty data (#109)

parent a66df3e4
......@@ -287,6 +287,9 @@ func NewDecryptionCipherCtx(c *Cipher, e *Engine, key, iv []byte) (
}
func (ctx *encryptionCipherCtx) EncryptUpdate(input []byte) ([]byte, error) {
if len(input) == 0 {
return nil, nil
}
outbuf := make([]byte, len(input)+ctx.BlockSize())
outlen := C.int(len(outbuf))
res := C.EVP_EncryptUpdate(ctx.ctx, (*C.uchar)(&outbuf[0]), &outlen,
......@@ -298,6 +301,9 @@ func (ctx *encryptionCipherCtx) EncryptUpdate(input []byte) ([]byte, error) {
}
func (ctx *decryptionCipherCtx) DecryptUpdate(input []byte) ([]byte, error) {
if len(input) == 0 {
return nil, nil
}
outbuf := make([]byte, len(input)+ctx.BlockSize())
outlen := C.int(len(outbuf))
res := C.EVP_DecryptUpdate(ctx.ctx, (*C.uchar)(&outbuf[0]), &outlen,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment