From 8bfbae668752f7931c5b88a86105906198817402 Mon Sep 17 00:00:00 2001 From: Michal Simon Date: Thu, 4 Jul 2019 17:31:06 +0200 Subject: [PATCH] [XrdSecgsi] XrdSecProtocolgsi::Encrypt - set IV correctly and report correct size. closes #1018 --- src/XrdSecgsi/XrdSecProtocolgsi.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/XrdSecgsi/XrdSecProtocolgsi.cc b/src/XrdSecgsi/XrdSecProtocolgsi.cc index c4a7cd63f9a..9f6a2d0d551 100644 --- a/src/XrdSecgsi/XrdSecProtocolgsi.cc +++ b/src/XrdSecgsi/XrdSecProtocolgsi.cc @@ -1087,8 +1087,8 @@ int XrdSecProtocolgsi::Encrypt(const char *inbuf, // Data to be encrypted int liv = 0; char *iv = 0; if (useIV) { - iv = sessionKey->RefreshIV(liv); - sessionKey->SetIV(liv, iv); + iv = sessionKey->RefreshIV(liv); // no need to call sessionKeySetIV as + // RefreshIV will set the internal value } // Get output buffer @@ -1099,7 +1099,8 @@ int XrdSecProtocolgsi::Encrypt(const char *inbuf, // Data to be encrypted memcpy(buf, iv, liv); // Encrypt - int len = sessionKey->Encrypt(inbuf, inlen, buf + liv); + int len = sessionKey->Encrypt(inbuf, inlen, buf + liv) + liv; // the size of initialization vector which is being appended at + // the beginning of the output buffer has to be taken into account if (len <= 0) { SafeFree(buf); return -EINVAL;