Skip to content

Commit 25b397a

Browse files
committed
GCM: bugfix: correct constants for max length values
Signed-off-by: Joerg Schmidbauer <jschmidb@de.ibm.com>
1 parent 4a771ec commit 25b397a

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

src/include/s390_gcm.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,23 @@
1616

1717
#include "s390_ctr.h"
1818

19-
#define S390_GCM_MAX_TEXT_LENGTH (0x0000000fffffffe0ul) /* (2^31)-32 */
20-
#define S390_GCM_MAX_AAD_LENGTH (0x2000000000000000ul) /* (2^61) */
21-
#define S390_GCM_MAX_IV_LENGTH (0x2000000000000000ul) /* (2^61) */
19+
/*
20+
* NIST SP 800-38d: bitlen(P) <= 2^39 - 256;
21+
* => 0 <= bytelen(P) <= 2^36 - 32
22+
*/
23+
#define S390_GCM_MAX_TEXT_LENGTH ((2ULL << 36) - 32)
24+
25+
/*
26+
* NIST SP 800-38d: bitlen(A) <= 2^64 - 1
27+
* => 0 <= bytelen(A) <= 2^61 - 1
28+
*/
29+
#define S390_GCM_MAX_AAD_LENGTH ((2ULL << 61) - 1)
30+
31+
/*
32+
* NIST SP 800-38d: 1 <= bitlen(iv) <= 2^64 - 1
33+
* => 1 <= bytelen(iv) <= 2^61 - 1
34+
*/
35+
#define S390_GCM_MAX_IV_LENGTH ((2ULL << 61) - 1)
2236

2337
/* the recommended iv length for GCM is 96 bit or 12 byte */
2438
#define GCM_RECOMMENDED_IV_LENGTH 12

0 commit comments

Comments
 (0)