summaryrefslogtreecommitdiff
path: root/cmac.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-05-13 19:23:24 -0400
committerJeffrey Walton <noloader@gmail.com>2017-05-13 19:23:24 -0400
commitbc2678478ce9bf008d3111b9414b3c05bd539213 (patch)
treee4551465deff5062e54c3c8c9216d40f7c44e5e4 /cmac.cpp
parentcea45eb024b73a11598fb9f9f697c00781c22db8 (diff)
downloadcryptopp-git-bc2678478ce9bf008d3111b9414b3c05bd539213.tar.gz
Add polynomial for 1024-bit block cipher.
This will support Threefish and its 1024-bit block size. I believe this is correct, but it may be wrong. According to "Table of Low-Weight Binary Irreducible Polynomials" (http://www.hpl.hp.com/techreports/98/HPL-98-135.pdf), the polynomial is x^1024 + x^19 + x^6 + x + 1.
Diffstat (limited to 'cmac.cpp')
-rw-r--r--cmac.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmac.cpp b/cmac.cpp
index ca04d0bd..1b56662d 100644
--- a/cmac.cpp
+++ b/cmac.cpp
@@ -31,15 +31,24 @@ static void MulU(byte *k, unsigned int length)
k[15] ^= 0x87;
break;
case 32:
- // Should this be 0x425?
+ // https://crypto.stackexchange.com/q/9815/10496
+ // Polynomial x^256 + x^10 + x^5 + x + 1
k[30] ^= 4;
k[31] ^= 0x23;
break;
case 64:
// https://crypto.stackexchange.com/q/9815/10496
+ // Polynomial x^512 + x^8 + x^5 + x^2 + 1
k[62] ^= 1;
k[63] ^= 0x25;
break;
+ case 128:
+ // https://crypto.stackexchange.com/q/9815/10496
+ // Polynomial x^1024 + x^19 + x^6 + x + 1
+ k[125] ^= 8;
+ k[126] ^= 0x00;
+ k[127] ^= 0x43;
+ break;
default:
throw InvalidArgument("CMAC: " + IntToString(length) + " is not a supported cipher block size");
}