Skip to content

Commit 819c7fd

Browse files
committed
Set w19 earlier before cipher-stealing of 1 block + tail.
1 parent 7da0924 commit 819c7fd

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

crypto/fipsmodule/modes/xts_test.cc

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,50 @@ struct XTSTestCase {
3434
};
3535

3636
static const XTSTestCase kXTSTestCases[] = {
37+
// tests that were failing:
38+
// ACCP test vector
39+
// https://github.com/corretto/amazon-corretto-crypto-provider/blob/a4c4876cceb6b3b8209b2a5cb57a2f38622146b9/tst/com/amazon/corretto/crypto/provider/test/AesXtsTest.java#L415
40+
// len = 24 bytes = 1 block + 8 bytes
41+
{
42+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
43+
"202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F",
44+
"000102030405060708090A0B0C0D0E0F",
45+
"000102030405060708090A0B0C0D0E0F1011121314151617",
46+
"770407bac58070c22a0d2b1c8b0ad644b82298441f93d2a0",
47+
},
48+
// other failing ones
49+
{
50+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
51+
"202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F",
52+
"000102030405060708090A0B0C0D0E0A",
53+
"000102030405060708090A0B0C0D0E0F10111213141516",
54+
"7ce0976476adfe592dd6a1815815781da3eabf2e5faa74",
55+
},
56+
{
57+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
58+
"202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E"
59+
"35",
60+
"000102030405060708090A0B0C0D0E0A",
61+
"000102030405060708090A0B0C0D0E0F10111213141516",
62+
"2f4de89842bb832dd96cf4293a2d1a4f740de1dccde3ab",
63+
},
64+
{
65+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
66+
"202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E"
67+
"35",
68+
"000102030405060708090A0B0C0D0E05",
69+
"000102030405060708090A0B0C0D0E0F10111213141516",
70+
"2aeae116c8f5fca3cd99cdd475b2e3e1a994639d8eb978",
71+
},
72+
{
73+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
74+
"202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E"
75+
"35",
76+
"000102030405060708090A0B0C0D0E0A",
77+
"000102030405060708090A0B0C0D0E0F1011121314151617",
78+
"ec639ea5987c576706713e36b05336ff740de1dccde3ab16",
79+
},
80+
3781
// Test vectors from OpenSSL 1.1.1d.
3882
// plaintext length = 32 blocks = 512 bytes
3983
{
@@ -238,6 +282,44 @@ static const XTSTestCase kXTSTestCases[] = {
238282
"000102030405060708090a0b0c0d0e0f101112131415",
239283
"75e8188bcce59ada939f57de2cb9a489c30ca8f2ed57",
240284
},
285+
// additional tests that were passing, when trying to figure out why the other ones were failing
286+
{
287+
"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0"
288+
"bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a0",
289+
"9a78563412000000000000000000000A",
290+
"000102030405060708090a0b0c0d0e0f1011121314151617",
291+
"57e8e7cde35c83b70fea50ec0129e25ab5bde4156e8ab6f5",
292+
},
293+
{
294+
"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0"
295+
"bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a0",
296+
"000102030405060708090A0B0C0D0E0A",
297+
"000102030405060708090a0b0c0d0e0f1011121314151617",
298+
"bb9b4595bd94766adc7ec2ba913c109aca30758281c77213",
299+
},
300+
{
301+
"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0"
302+
"bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a0",
303+
"000102030405060708090A0B0C0D0E0A",
304+
"000102030405060708090a0b0c0d0e0f10111213141516",
305+
"f2abc22f884f2a1d94570b4d43dc521aca30758281c772",
306+
},
307+
308+
{
309+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
310+
"202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F",
311+
"9a785634120000000000000000000000",
312+
"000102030405060708090A0B0C0D0E0F1011121314151617",
313+
"cd72ea12eeb4c85ca07a9366e66e9e491ad4aaecba8050a2",
314+
},
315+
{
316+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
317+
"202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F",
318+
"000102030405060708090A0B0C0D0E07",
319+
"000102030405060708090A0B0C0D0E0F1011121314151617",
320+
"0462384df00d699e5637933a5aa90a23c423b54aa5ae47d1",
321+
},
322+
241323
// https://github.com/BrianGladman/modes/blob/master/testvals/xts.6#L433
242324
// VEC 45, len = 31 bytes = 1 block + 15 bytes
243325
{
@@ -290,6 +372,17 @@ static const XTSTestCase kXTSTestCases[] = {
290372
"6f229c1b60833e2a50a041b360d991814c6ec7f3199d8b2482f5b19b64c32013"
291373
"a679f1361a011bf37b2e1565"
292374
},
375+
376+
{
377+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
378+
"202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F",
379+
"000102030405060708090A0B0C0D0E0F",
380+
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
381+
"202122232425262F",
382+
"b82298441f93d2a0ad34668c7df66e4c8544720992ae2ecc0462c41fa816109f"
383+
"9ce4d6a936a41f0f",
384+
},
385+
293386
// len = 51 bytes = 3 blocks + 3 bytes
294387
{
295388
"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0"

third_party/s2n-bignum/s2n-bignum-to-be-imported/arm/aes/aes-xts-enc.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ S2N_BN_SYMBOL(aes_hw_xts_encrypt):
104104

105105
// Encryption
106106
.Lxts_enc:
107+
mov w19, #0x87
107108
cmp x2, #0x20
108109
b.lo .Lxts_enc_tail1x // when input = 1 with tail
109110

@@ -112,7 +113,6 @@ S2N_BN_SYMBOL(aes_hw_xts_encrypt):
112113
// the five ivs stored into, v6.16b,v8.16b,v9.16b,v10.16b,v11.16b
113114
fmov x9, d6
114115
fmov x10, v6.d[1]
115-
mov w19, #0x87
116116
tweak(d8, v8.d[1])
117117

118118
cmp x2, #0x30

0 commit comments

Comments
 (0)