From dbc648baa43840fb16a3b038c443a0d0aefc3224 Mon Sep 17 00:00:00 2001 From: sp0001 Date: Tue, 8 Oct 2024 10:15:43 +0200 Subject: [PATCH] Modified string encodings in JSON tags. --- draft-irtf-cfrg-cpace.md | 40 ++++++++++++++++----------------- poc/CPace_string_utils.sage | 44 ++++++++++++++++++------------------- poc/README | 7 ++++++ testvectors.md | 40 ++++++++++++++++----------------- 4 files changed, 69 insertions(+), 62 deletions(-) create mode 100644 poc/README diff --git a/draft-irtf-cfrg-cpace.md b/draft-irtf-cfrg-cpace.md index 881a54c..990e9fd 100644 --- a/draft-irtf-cfrg-cpace.md +++ b/draft-irtf-cfrg-cpace.md @@ -1063,10 +1063,10 @@ With the above definition of lexiographical ordering ordered concatenation is sp ~~~ test-vectors - #eyJiXCJBQkNEXCIiOiAiNDE0MjQzNDQiLCAiYlwiQkNEXCIiOiAiNDI0MzQ0IiwgIm - #JcIkFCQ0RFXCIiOiAiNDE0MjQzNDQ0NSIsICJvX2NhdChiXCJBQkNEXCIsYlwiQkNE - #XCIpIjogIjZGNjM0MjQzNDQ0MTQyNDM0NCIsICJvX2NhdChiXCJCQ0RcIixiXCJBQk - #NERVwiKSI6ICI2RjYzNDI0MzQ0NDE0MjQzNDQ0NSJ9 + #eyJiJ0FCQ0QnIjogIjQxNDI0MzQ0IiwgImInQkNEJyI6ICI0MjQzNDQiLCAiYidBQk + #NERSciOiAiNDE0MjQzNDQ0NSIsICJvX2NhdChiJ0FCQ0QnLGInQkNEJykiOiAiNkY2 + #MzQyNDM0NDQxNDI0MzQ0IiwgIm9fY2F0KGInQkNEJyxiJ0FCQ0RFJykiOiAiNkY2Mz + #QyNDM0NDQxNDI0MzQ0NDUifQ== ~~~ @@ -1094,14 +1094,14 @@ def transcript_ir(Ya,ADa,Yb,ADb): ~~~ test-vectors - #eyJiXCIxMjNcIiI6ICIzMTMyMzMiLCAiYlwiMjM0XCIiOiAiMzIzMzM0IiwgImJcIl - #BhcnR5QVwiIjogIjUwNjE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- a/poc/CPace_string_utils.sage +++ b/poc/CPace_string_utils.sage @@ -298,11 +298,11 @@ With the above definition of lexiographical ordering ordered concatenation is sp print ("~~~", file = file) result_dict = {} - result_dict['b"ABCD"'] = byte_string_to_json(b"ABCD") - result_dict['b"BCD"'] = byte_string_to_json(b"BCD") - result_dict['b"ABCDE"'] = byte_string_to_json(b"ABCDE") - result_dict['o_cat(b"ABCD",b"BCD")'] = byte_string_to_json(o_cat(b"ABCD",b"BCD")) - result_dict['o_cat(b"BCD",b"ABCDE")'] = byte_string_to_json(o_cat(b"BCD",b"ABCDE")) + result_dict["b'ABCD'"] = byte_string_to_json(b"ABCD") + result_dict["b'BCD'"] = byte_string_to_json(b"BCD") + result_dict["b'ABCDE'"] = byte_string_to_json(b"ABCDE") + result_dict["o_cat(b'ABCD',b'BCD')"] = byte_string_to_json(o_cat(b"ABCD",b"BCD")) + result_dict["o_cat(b'BCD',b'ABCDE')"] = byte_string_to_json(o_cat(b"BCD",b"ABCDE")) print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file) tv_output_python_dictionary_as_json_base64(result_dict,file=file) @@ -332,14 +332,14 @@ def transcript_ir(Ya,ADa,Yb,ADb): print ("~~~", file = file) result_dict = {} - result_dict['b"123"'] = byte_string_to_json(b"123") - result_dict['b"234"'] = byte_string_to_json(b"234") - result_dict['b"PartyA"'] = byte_string_to_json(b"PartyA") - result_dict['b"PartyB"'] = byte_string_to_json(b"PartyB") - result_dict['b"3456"'] = byte_string_to_json(b"3456") - result_dict['b"2345"'] = byte_string_to_json(b"2345") - result_dict['transcript_ir(b"123",b"PartyA",b"234",b"PartyB")'] = byte_string_to_json(transcript_ir(b"123",b"PartyA",b"234",b"PartyB")) - result_dict['transcript_ir(b"3456",b"PartyA",b"2345",b"PartyB")'] = byte_string_to_json(transcript_ir(b"3456",b"PartyA",b"2345",b"PartyB")) + result_dict["b'123'"] = byte_string_to_json(b"123") + result_dict["b'234'"] = byte_string_to_json(b"234") + result_dict["b'PartyA'"] = byte_string_to_json(b"PartyA") + result_dict["b'PartyB'"] = byte_string_to_json(b"PartyB") + result_dict["b'3456'"] = byte_string_to_json(b"3456") + result_dict["b'2345'"] = byte_string_to_json(b"2345") + result_dict["transcript_ir(b'123',b'PartyA',b'234',b'PartyB')"] = byte_string_to_json(transcript_ir(b"123",b"PartyA",b"234",b"PartyB")) + result_dict["transcript_ir(b'3456',b'PartyA',b'2345',b'PartyB')"] = byte_string_to_json(transcript_ir(b"3456",b"PartyA",b"2345",b"PartyB")) print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file) tv_output_python_dictionary_as_json_base64(result_dict,file=file) @@ -368,14 +368,14 @@ def transcript_oc(Ya,ADa,Yb,ADb): print ("~~~", file = file) result_dict = {} - result_dict['b"123"'] = byte_string_to_json(b"123") - result_dict['b"234"'] = byte_string_to_json(b"234") - result_dict['b"PartyA"'] = byte_string_to_json(b"PartyA") - result_dict['b"PartyB"'] = byte_string_to_json(b"PartyB") - result_dict['b"3456"'] = byte_string_to_json(b"3456") - result_dict['b"2345"'] = byte_string_to_json(b"2345") - result_dict['transcript_oc(b"123",b"PartyA",b"234",b"PartyB")'] = byte_string_to_json(transcript_oc(b"123",b"PartyA",b"234",b"PartyB")) - result_dict['transcript_oc(b"3456",b"PartyA",b"2345",b"PartyB")'] = byte_string_to_json(transcript_oc(b"3456",b"PartyA",b"2345",b"PartyB")) + result_dict["b'123'"] = byte_string_to_json(b"123") + result_dict["b'234'"] = byte_string_to_json(b"234") + result_dict["b'PartyA'"] = byte_string_to_json(b"PartyA") + result_dict["b'PartyB'"] = byte_string_to_json(b"PartyB") + result_dict["b'3456'"] = byte_string_to_json(b"3456") + result_dict["b'2345'"] = byte_string_to_json(b"2345") + result_dict["transcript_oc(b'123',b'PartyA',b'234',b'PartyB')"] = byte_string_to_json(transcript_oc(b"123",b"PartyA",b"234",b"PartyB")) + result_dict["transcript_oc(b'3456',b'PartyA',b'2345',b'PartyB')"] = byte_string_to_json(transcript_oc(b"3456",b"PartyA",b"2345",b"PartyB")) print ("\n#### Testvectors as JSON file encoded as BASE64\n", file=file) tv_output_python_dictionary_as_json_base64(result_dict,file=file) @@ -390,7 +390,7 @@ def random_bytes(length): values = [randint(0, 255) for i in range(length)] result = b"" for v in values: - result += v.to_bytes(1, 'little') + result += v.to_bytes(1, little) return result if __name__ == "__main__": diff --git a/poc/README b/poc/README new file mode 100644 index 0000000..0be804c --- /dev/null +++ b/poc/README @@ -0,0 +1,7 @@ +For generating test vectors with sage use + +make clean +make +make testvectors + +There will be a json file and a markdown file generated and stored at ../ diff --git a/testvectors.md b/testvectors.md index 702acc3..deae522 100644 --- a/testvectors.md +++ b/testvectors.md @@ -168,10 +168,10 @@ With the above definition of lexiographical ordering ordered concatenation is sp ~~~ test-vectors - #eyJiXCJBQkNEXCIiOiAiNDE0MjQzNDQiLCAiYlwiQkNEXCIiOiAiNDI0MzQ0IiwgIm - #JcIkFCQ0RFXCIiOiAiNDE0MjQzNDQ0NSIsICJvX2NhdChiXCJBQkNEXCIsYlwiQkNE - #XCIpIjogIjZGNjM0MjQzNDQ0MTQyNDM0NCIsICJvX2NhdChiXCJCQ0RcIixiXCJBQk - #NERVwiKSI6ICI2RjYzNDI0MzQ0NDE0MjQzNDQ0NSJ9 + #eyJiJ0FCQ0QnIjogIjQxNDI0MzQ0IiwgImInQkNEJyI6ICI0MjQzNDQiLCAiYidBQk + #NERSciOiAiNDE0MjQzNDQ0NSIsICJvX2NhdChiJ0FCQ0QnLGInQkNEJykiOiAiNkY2 + #MzQyNDM0NDQxNDI0MzQ0IiwgIm9fY2F0KGInQkNEJyxiJ0FCQ0RFJykiOiAiNkY2Mz + #QyNDM0NDQxNDI0MzQ0NDUifQ== ~~~ @@ -199,14 +199,14 @@ def transcript_ir(Ya,ADa,Yb,ADb): ~~~ test-vectors - #eyJiXCIxMjNcIiI6ICIzMTMyMzMiLCAiYlwiMjM0XCIiOiAiMzIzMzM0IiwgImJcIl - #BhcnR5QVwiIjogIjUwNjE3M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