Skip to content

Commit 0f79ecc

Browse files
author
Lucas McDonald
committed
sync
1 parent d75b611 commit 0f79ecc

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

DynamoDbEncryption/dafny/DynamoDbEncryption/test/DynamoToStruct.dfy

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,14 @@ module DynamoToStructTest {
376376
//= type=test
377377
//# Entries in a String Set MUST be ordered in ascending [UTF-16 binary order](./string-ordering.md#utf-16-binary-order).
378378
method {:test} TestSortSSAttr() {
379-
// "\ud800\udc02" <-> "𐀂"
380379
var stringSetValue := AttributeValue.SS(["&","。","\ud800\udc02"]);
381380
// Note that string values are UTF-8 encoded, but sorted by UTF-16 encoding.
382381
var encodedStringSetData := StructuredDataTerminal(value := [
383382
0,0,0,3, // 3 entries in set
384383
0,0,0,1, // 1st entry is 1 byte
385384
0x26, // "&" in UTF-8 encoding
386385
0,0,0,4, // 2nd entry is 4 bytes
387-
0xF0,0x90,0x80,0x82, // "𐀂" in UTF-8 encoding
386+
0xF0,0x90,0x80,0x82, // "\ud800\udc02" in UTF-8 encoding
388387
0,0,0,3, // 3rd entry is 3 bytes
389388
0xEF,0xBD,0xA1 // "。" in UTF-8 encoding
390389
],
@@ -396,7 +395,6 @@ module DynamoToStructTest {
396395

397396
var newStringSetValue := StructuredToAttr(encodedStringSetData);
398397
expect newStringSetValue.Success?;
399-
// "\ud800\udc02" <-> "𐀂"
400398
expect newStringSetValue.value == AttributeValue.SS(["&","\ud800\udc02","。"]);
401399
}
402400

@@ -417,12 +415,10 @@ module DynamoToStructTest {
417415

418416
method {:test} TestSetsInListAreSorted() {
419417
var nSetValue := AttributeValue.NS(["2","1","10"]);
420-
// "\ud800\udc02" <-> "𐀂"
421418
var sSetValue := AttributeValue.SS(["&","。","\ud800\udc02"]);
422419
var bSetValue := AttributeValue.BS([[1,0],[1],[2]]);
423420

424421
var sortedNSetValue := AttributeValue.NS(["1","10","2"]);
425-
// "\ud800\udc02" <-> "𐀂"
426422
var sortedSSetValue := AttributeValue.SS(["&","\ud800\udc02","。"]);
427423
var sortedBSetValue := AttributeValue.BS([[1],[1,0],[2]]);
428424

@@ -448,12 +444,10 @@ module DynamoToStructTest {
448444

449445
method {:test} TestSetsInMapAreSorted() {
450446
var nSetValue := AttributeValue.NS(["2","1","10"]);
451-
// "\ud800\udc02" <-> "𐀂"
452447
var sSetValue := AttributeValue.SS(["&","。","\ud800\udc02"]);
453448
var bSetValue := AttributeValue.BS([[1,0],[1],[2]]);
454449

455450
var sortedNSetValue := AttributeValue.NS(["1","10","2"]);
456-
// "\ud800\udc02" <-> "𐀂"
457451
var sortedSSetValue := AttributeValue.SS(["&","\ud800\udc02","。"]);
458452
var sortedBSetValue := AttributeValue.BS([[1],[1,0],[2]]);
459453

@@ -496,7 +490,6 @@ module DynamoToStructTest {
496490
method {:test} TestSortMapKeys() {
497491
var nullValue := AttributeValue.NULL(true);
498492

499-
// "\ud800\udc02" <-> "𐀂"
500493
var mapValue := AttributeValue.M(map["&" := nullValue, "。" := nullValue, "\ud800\udc02" := nullValue]);
501494

502495
// Note that the string values are encoded as UTF-8, but are sorted according to UTF-16 encoding.
@@ -507,7 +500,7 @@ module DynamoToStructTest {
507500
0x26, // "&" UTF-8 encoded
508501
0,0, 0,0,0,0, // null value
509502
0,1, 0,0,0,4, // 2nd key is a string 4 bytes long
510-
0xF0, 0x90, 0x80, 0x82, // "𐀂" UTF-8 encoded
503+
0xF0, 0x90, 0x80, 0x82, // "\ud800\udc02" UTF-8 encoded
511504
0,0, 0,0,0,0, // null value
512505
0,1, 0,0,0,3, // 3rd key is a string 3 bytes long
513506
0xEF, 0xBD, 0xA1, // "。"

TestVectors/dafny/DDBEncryption/src/WriteManifest.dfy

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,20 +218,21 @@ module {:options "-functionSyntax:4"} WriteManifest {
218218
const DoNothing : CryptoAction := 3
219219

220220
const A : string := "A"
221-
const B : string := "\ud000" // "Ud000" <-> "퀀"
222-
const C : string := "\ufe4c" // "Ufe4c" <-> "﹌"
223-
const D : string := "\u10001" // "U10001" <-> "𐀁" (surrogate pair: "\uD800\uDC01")
224-
const E : string := "\u10002" // "U10002" <-> "𐀂" (same high surrogate as D: "\uD800\uDC02")
225-
const F : string := "\u20002" // "U20002" <-> "𠀂" (different high surrogate as D: "\D840\uDC02")
221+
const B : string := "\ud000" // Ud000"
222+
const C : string := "\ufe4c" // Ufe4c"
223+
const D : string := "\u100001" // U10001
224+
const E : string := "\u100002" // U10002 - same high surrogate as D
225+
const F : string := "\u200002" // U20002 - different high surrogate as D
226226

227-
lemma CheckLengths()
228-
ensures |A| == 1
229-
ensures |B| == 1
230-
ensures |C| == 1
231-
ensures |D| == 2
232-
ensures |E| == 2
233-
ensures |F| == 2
234-
{}
227+
// Dafny doesn't handle unicode surrogates correctly.
228+
// lemma CheckLengths()
229+
// ensures |A| == 1
230+
// ensures |B| == 1
231+
// ensures |C| == 1
232+
// ensures |D| == 2
233+
// ensures |E| == 2
234+
// ensures |F| == 2
235+
// {}
235236

236237
// Let's make attribute names with complex characters.
237238
// It shouldn't matter, but let's make sure

0 commit comments

Comments
 (0)