diff options
author | Mohammed Attia <skeuomorf@gmail.com> | 2014-03-12 20:07:05 +0200 |
---|---|---|
committer | Mohammed Attia <skeuomorf@gmail.com> | 2014-03-13 12:33:40 +0200 |
commit | 49b92596b693d90233b66007e1a76bbd75e00f0c (patch) | |
tree | f8a417599085a77420095f6e0779909e8a30e68a /tests | |
parent | 22ccb8771f9479809810506cf04b5175e1c7957c (diff) | |
download | cryptography-49b92596b693d90233b66007e1a76bbd75e00f0c.tar.gz cryptography-49b92596b693d90233b66007e1a76bbd75e00f0c.tar.bz2 cryptography-49b92596b693d90233b66007e1a76bbd75e00f0c.zip |
Change flag to a bool
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_utils.py | 186 | ||||
-rw-r--r-- | tests/utils.py | 24 |
2 files changed, 104 insertions, 106 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index 064011c3..643860dc 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1214,110 +1214,108 @@ a17f4550590378f2b074030c20e36911598a1018772f61be3b24de4be5a388ccc09e15a92819c3\ """).splitlines() expected_vectors = [ - {'g': '06b7861abbd35cc89e79c52f68d20875389b127361ca66\ -822138ce4991d2b862259d6b4548a6495b195aa0e0b6137ca37eb23b94074d3c3\ -d300042bdf15762812b6333ef7b07ceba78607610fcc9ee68491dbc1e34cd1261\ -5474e52b18bc934fb00c61d39e7da8902291c4434a4e2224c3f4fd9f93cd6f4f1\ -7fc076341a7e7d9', - 'p': 'd38311e2cd388c3ed698e82fdf88eb92b5a9a483dc8800\ -5d4b725ef341eabb47cf8a7a8a41e792a156b7ce97206c4f9c5ce6fc5ae791210\ -2b6b502e59050b5b21ce263dddb2044b652236f4d42ab4b5d6aa73189cef1ace7\ -78d7845a5c1c1c7147123188f8dc551054ee162b634d60f097f719076640e2098\ -0a0093113a8bd73', + {'g': '06b7861abbd35cc89e79c52f68d20875389b127361ca66' + '822138ce4991d2b862259d6b4548a6495b195aa0e0b6137ca37eb23b94074d3c3' + 'd300042bdf15762812b6333ef7b07ceba78607610fcc9ee68491dbc1e34cd1261' + '5474e52b18bc934fb00c61d39e7da8902291c4434a4e2224c3f4fd9f93cd6f4f1' + '7fc076341a7e7d9', + 'p': 'd38311e2cd388c3ed698e82fdf88eb92b5a9a483dc8800' + '5d4b725ef341eabb47cf8a7a8a41e792a156b7ce97206c4f9c5ce6fc5ae791210' + '2b6b502e59050b5b21ce263dddb2044b652236f4d42ab4b5d6aa73189cef1ace7' + '78d7845a5c1c1c7147123188f8dc551054ee162b634d60f097f719076640e2098' + '0a0093113a8bd73', 'q': '96c5390a8b612c0e422bb2b0ea194a3ec935a281', 'x': '8185fee9cc7c0e91fd85503274f1cd5a3fd15a49', - 'y': '6f26d98d41de7d871b6381851c9d91fa03942092ab6097\ -e76422070edb71db44ff568280fdb1709f8fc3feab39f1f824adaeb2a29808815\ -6ac31af1aa04bf54f475bdcfdcf2f8a2dd973e922d83e76f016558617603129b2\ -1c70bf7d0e5dc9e68fe332e295b65876eb9a12fe6fca9f1a1ce80204646bf99b5\ -771d249a6fea627'}, - {'g': '06b7861abbd35cc89e79c52f68d20875389b127361ca66822138\ - ce4991d2b862259d6b4548a6495b195aa0e0b6137ca37eb23b94074d3c3d30004\ - 2bdf15762812b6333ef7b07ceba78607610fcc9ee68491dbc1e34cd12615474e5\ - 2b18bc934fb00c61d39e7da8902291c4434a4e2224c3f4fd9f93cd6f4f17fc076\ - 341a7e7d9', - 'p': 'd38311e2cd388c3ed698e82fdf88eb92b5a9a483dc88005d4b72\ - 5ef341eabb47cf8a7a8a41e792a156b7ce97206c4f9c5ce6fc5ae7912102b6b50\ - 2e59050b5b21ce263dddb2044b652236f4d42ab4b5d6aa73189cef1ace778d784\ - 5a5c1c1c7147123188f8dc551054ee162b634d60f097f719076640e20980a0093\ - 113a8bd73', + 'y': '6f26d98d41de7d871b6381851c9d91fa03942092ab6097' + 'e76422070edb71db44ff568280fdb1709f8fc3feab39f1f824adaeb2a29808815' + '6ac31af1aa04bf54f475bdcfdcf2f8a2dd973e922d83e76f016558617603129b2' + '1c70bf7d0e5dc9e68fe332e295b65876eb9a12fe6fca9f1a1ce80204646bf99b5' + '771d249a6fea627'}, + {'g': '06b7861abbd35cc89e79c52f68d20875389b127361ca66822138' + 'ce4991d2b862259d6b4548a6495b195aa0e0b6137ca37eb23b94074d3c3d30004' + '2bdf15762812b6333ef7b07ceba78607610fcc9ee68491dbc1e34cd12615474e5' + '2b18bc934fb00c61d39e7da8902291c4434a4e2224c3f4fd9f93cd6f4f17fc076' + '341a7e7d9', + 'p': 'd38311e2cd388c3ed698e82fdf88eb92b5a9a483dc88005d4b72' + '5ef341eabb47cf8a7a8a41e792a156b7ce97206c4f9c5ce6fc5ae7912102b6b50' + '2e59050b5b21ce263dddb2044b652236f4d42ab4b5d6aa73189cef1ace778d784' + '5a5c1c1c7147123188f8dc551054ee162b634d60f097f719076640e20980a0093' + '113a8bd73', 'q': '96c5390a8b612c0e422bb2b0ea194a3ec935a281', 'x': '85322d6ea73083064376099ca2f65f56e8522d9b', - 'y': '21f8690f717c9f4dcb8f4b6971de2f15b9231fcf41b7eeb997d7\ - 81f240bfdddfd2090d22083c26cca39bf37c9caf1ec89518ea64845a50d747b49\ - 131ffff6a2fd11ea7bacbb93c7d05137383a06365af82225dd3713ca5a4500631\ - 6f53bd12b0e260d5f79795e5a4c9f353f12867a1d3202394673ada8563b71555e\ - 53f415254'}, - {'g': 'e4c4eca88415b23ecf811c96e48cd24200fe916631a68a684e6c\ - cb6b1913413d344d1d8d84a333839d88eee431521f6e357c16e6a93be111a9807\ - 6739cd401bab3b9d565bf4fb99e9d185b1e14d61c93700133f908bae03e28764d\ - 107dcd2ea7674217622074bb19efff482f5f5c1a86d5551b2fc68d1c6e9d80119\ - 58ef4b9c2a3a55d0d3c882e6ad7f9f0f3c61568f78d0706b10a26f23b4f197c32\ - 2b825002284a0aca91807bba98ece912b80e10cdf180cf99a35f210c1655fbfdd\ - 74f13b1b5046591f8403873d12239834dd6c4eceb42bf7482e1794a1601357b62\ - 9ddfa971f2ed273b146ec1ca06d0adf55dd91d65c37297bda78c6d210c0bc26e5\ - 58302', - 'p': 'ea1fb1af22881558ef93be8a5f8653c5a559434c49c8c2c12ace\ - 5e9c41434c9cf0a8e9498acb0f4663c08b4484eace845f6fb17dac62c98e706af\ - 0fc74e4da1c6c2b3fbf5a1d58ff82fc1a66f3e8b12252c40278fff9dd7f102eed\ - 2cb5b7323ebf1908c234d935414dded7f8d244e54561b0dca39b301de8c49da9f\ - b23df33c6182e3f983208c560fb5119fbf78ebe3e6564ee235c6a15cbb9ac247b\ - aba5a423bc6582a1a9d8a2b4f0e9e3d9dbac122f750dd754325135257488b1f6e\ - cabf21bff2947fe0d3b2cb7ffe67f4e7fcdf1214f6053e72a5bb0dd20a0e9fe6d\ - b2df0a908c36e95e60bf49ca4368b8b892b9c79f61ef91c47567c40e1f80ac5aa\ - 66ef7', - 'q': '8ec73f3761caf5fdfe6e4e82098bf10f898740dcb808204bf6b1\ - 8f507192c19d', - 'x': '405772da6e90d809e77d5de796562a2dd4dfd10ef00a83a3aba6\ - bd818a0348a1', - 'y': '6b32e31ab9031dc4dd0b5039a78d07826687ab087ae6de4736f5\ - b0434e1253092e8a0b231f9c87f3fc8a4cb5634eb194bf1b638b7a7889620ce67\ - 11567e36aa36cda4604cfaa601a45918371d4ccf68d8b10a50a0460eb1dc0fff6\ - 2ef5e6ee4d473e18ea4a66c196fb7e677a49b48241a0b4a97128eff30fa437050\ - 501a584f8771e7280d26d5af30784039159c11ebfea10b692fd0a58215eeb18bf\ - f117e13f08db792ed4151a218e4bed8dddfb0793225bd1e9773505166f4bd8ced\ - bb286ea28232972da7bae836ba97329ba6b0a36508e50a52a7675e476d4d4137e\ - ae13f22a9d2fefde708ba8f34bf336c6e76331761e4b0617633fe7ec3f23672fb\ - 19d27'}, - {'g': 'e4c4eca88415b23ecf811c96e48cd24200fe916631a68a684e6c\ - cb6b1913413d344d1d8d84a333839d88eee431521f6e357c16e6a93be111a9807\ - 6739cd401bab3b9d565bf4fb99e9d185b1e14d61c93700133f908bae03e28764d\ - 107dcd2ea7674217622074bb19efff482f5f5c1a86d5551b2fc68d1c6e9d80119\ - 58ef4b9c2a3a55d0d3c882e6ad7f9f0f3c61568f78d0706b10a26f23b4f197c32\ - 2b825002284a0aca91807bba98ece912b80e10cdf180cf99a35f210c1655fbfdd\ - 74f13b1b5046591f8403873d12239834dd6c4eceb42bf7482e1794a1601357b62\ - 9ddfa971f2ed273b146ec1ca06d0adf55dd91d65c37297bda78c6d210c0bc26e5\ - 58302', - 'p': 'ea1fb1af22881558ef93be8a5f8653c5a559434c49c8c2c12ace\ - 5e9c41434c9cf0a8e9498acb0f4663c08b4484eace845f6fb17dac62c98e706af\ - 0fc74e4da1c6c2b3fbf5a1d58ff82fc1a66f3e8b12252c40278fff9dd7f102eed\ - 2cb5b7323ebf1908c234d935414dded7f8d244e54561b0dca39b301de8c49da9f\ - b23df33c6182e3f983208c560fb5119fbf78ebe3e6564ee235c6a15cbb9ac247b\ - aba5a423bc6582a1a9d8a2b4f0e9e3d9dbac122f750dd754325135257488b1f6e\ - cabf21bff2947fe0d3b2cb7ffe67f4e7fcdf1214f6053e72a5bb0dd20a0e9fe6d\ - b2df0a908c36e95e60bf49ca4368b8b892b9c79f61ef91c47567c40e1f80ac5aa\ - 66ef7', - 'q': '8ec73f3761caf5fdfe6e4e82098bf10f898740dcb808204bf6b1\ - 8f507192c19d', - 'x': '0e0b95e31fda3f888059c46c3002ef8f2d6be112d0209aeb9e95\ - 45da67aeea80', - 'y': '778082b77ddba6f56597cc74c3a612abf2ddbd85cc81430c99ab\ - 843c1f630b9db0139965f563978164f9bf3a8397256be714625cd41cd7fa0067d\ - 94ea66d7e073f7125af692ad01371d4a17f4550590378f2b074030c20e3691159\ - 8a1018772f61be3b24de4be5a388ccc09e15a92819c31dec50de9fde105b49eaa\ - 097b9d13d9219eeb33b628facfd1c78a7159c8430d0647c506e7e3de74763cb35\ - 1eada72c00bef3c9641881e6254870c1e6599f8ca2f1bbb74f39a905e3a34e454\ - 4168e6e50c9e3305fd09cab6ed4aff6fda6e0d5bf375c81ac9054406d9193b003\ - c89272f1bd83d48250134b65c77c2b6332d38d34d9016f0e8975536ad6c348a1f\ - aedb0'} + 'y': '21f8690f717c9f4dcb8f4b6971de2f15b9231fcf41b7eeb997d7' + '81f240bfdddfd2090d22083c26cca39bf37c9caf1ec89518ea64845a50d747b49' + '131ffff6a2fd11ea7bacbb93c7d05137383a06365af82225dd3713ca5a4500631' + '6f53bd12b0e260d5f79795e5a4c9f353f12867a1d3202394673ada8563b71555e' + '53f415254'}, + {'g': 'e4c4eca88415b23ecf811c96e48cd24200fe916631a68a684e6c' + 'cb6b1913413d344d1d8d84a333839d88eee431521f6e357c16e6a93be111a9807' + '6739cd401bab3b9d565bf4fb99e9d185b1e14d61c93700133f908bae03e28764d' + '107dcd2ea7674217622074bb19efff482f5f5c1a86d5551b2fc68d1c6e9d80119' + '58ef4b9c2a3a55d0d3c882e6ad7f9f0f3c61568f78d0706b10a26f23b4f197c32' + '2b825002284a0aca91807bba98ece912b80e10cdf180cf99a35f210c1655fbfdd' + '74f13b1b5046591f8403873d12239834dd6c4eceb42bf7482e1794a1601357b62' + '9ddfa971f2ed273b146ec1ca06d0adf55dd91d65c37297bda78c6d210c0bc26e5' + '58302', + 'p': 'ea1fb1af22881558ef93be8a5f8653c5a559434c49c8c2c12ace' + '5e9c41434c9cf0a8e9498acb0f4663c08b4484eace845f6fb17dac62c98e706af' + '0fc74e4da1c6c2b3fbf5a1d58ff82fc1a66f3e8b12252c40278fff9dd7f102eed' + '2cb5b7323ebf1908c234d935414dded7f8d244e54561b0dca39b301de8c49da9f' + 'b23df33c6182e3f983208c560fb5119fbf78ebe3e6564ee235c6a15cbb9ac247b' + 'aba5a423bc6582a1a9d8a2b4f0e9e3d9dbac122f750dd754325135257488b1f6e' + 'cabf21bff2947fe0d3b2cb7ffe67f4e7fcdf1214f6053e72a5bb0dd20a0e9fe6d' + 'b2df0a908c36e95e60bf49ca4368b8b892b9c79f61ef91c47567c40e1f80ac5aa' + '66ef7', + 'q': '8ec73f3761caf5fdfe6e4e82098bf10f898740dcb808204bf6b1' + '8f507192c19d', + 'x': '405772da6e90d809e77d5de796562a2dd4dfd10ef00a83a3aba6' + 'bd818a0348a1', + 'y': '6b32e31ab9031dc4dd0b5039a78d07826687ab087ae6de4736f5' + 'b0434e1253092e8a0b231f9c87f3fc8a4cb5634eb194bf1b638b7a7889620ce67' + '11567e36aa36cda4604cfaa601a45918371d4ccf68d8b10a50a0460eb1dc0fff6' + '2ef5e6ee4d473e18ea4a66c196fb7e677a49b48241a0b4a97128eff30fa437050' + '501a584f8771e7280d26d5af30784039159c11ebfea10b692fd0a58215eeb18bf' + 'f117e13f08db792ed4151a218e4bed8dddfb0793225bd1e9773505166f4bd8ced' + 'bb286ea28232972da7bae836ba97329ba6b0a36508e50a52a7675e476d4d4137e' + 'ae13f22a9d2fefde708ba8f34bf336c6e76331761e4b0617633fe7ec3f23672fb' + '19d27'}, + {'g': 'e4c4eca88415b23ecf811c96e48cd24200fe916631a68a684e6c' + 'cb6b1913413d344d1d8d84a333839d88eee431521f6e357c16e6a93be111a9807' + '6739cd401bab3b9d565bf4fb99e9d185b1e14d61c93700133f908bae03e28764d' + '107dcd2ea7674217622074bb19efff482f5f5c1a86d5551b2fc68d1c6e9d80119' + '58ef4b9c2a3a55d0d3c882e6ad7f9f0f3c61568f78d0706b10a26f23b4f197c32' + '2b825002284a0aca91807bba98ece912b80e10cdf180cf99a35f210c1655fbfdd' + '74f13b1b5046591f8403873d12239834dd6c4eceb42bf7482e1794a1601357b62' + '9ddfa971f2ed273b146ec1ca06d0adf55dd91d65c37297bda78c6d210c0bc26e5' + '58302', + 'p': 'ea1fb1af22881558ef93be8a5f8653c5a559434c49c8c2c12ace' + '5e9c41434c9cf0a8e9498acb0f4663c08b4484eace845f6fb17dac62c98e706af' + '0fc74e4da1c6c2b3fbf5a1d58ff82fc1a66f3e8b12252c40278fff9dd7f102eed' + '2cb5b7323ebf1908c234d935414dded7f8d244e54561b0dca39b301de8c49da9f' + 'b23df33c6182e3f983208c560fb5119fbf78ebe3e6564ee235c6a15cbb9ac247b' + 'aba5a423bc6582a1a9d8a2b4f0e9e3d9dbac122f750dd754325135257488b1f6e' + 'cabf21bff2947fe0d3b2cb7ffe67f4e7fcdf1214f6053e72a5bb0dd20a0e9fe6d' + 'b2df0a908c36e95e60bf49ca4368b8b892b9c79f61ef91c47567c40e1f80ac5aa' + '66ef7', + 'q': '8ec73f3761caf5fdfe6e4e82098bf10f898740dcb808204bf6b1' + '8f507192c19d', + 'x': '0e0b95e31fda3f888059c46c3002ef8f2d6be112d0209aeb9e95' + '45da67aeea80', + 'y': '778082b77ddba6f56597cc74c3a612abf2ddbd85cc81430c99ab' + '843c1f630b9db0139965f563978164f9bf3a8397256be714625cd41cd7fa0067d' + '94ea66d7e073f7125af692ad01371d4a17f4550590378f2b074030c20e3691159' + '8a1018772f61be3b24de4be5a388ccc09e15a92819c31dec50de9fde105b49eaa' + '097b9d13d9219eeb33b628facfd1c78a7159c8430d0647c506e7e3de74763cb35' + '1eada72c00bef3c9641881e6254870c1e6599f8ca2f1bbb74f39a905e3a34e454' + '4168e6e50c9e3305fd09cab6ed4aff6fda6e0d5bf375c81ac9054406d9193b003' + 'c89272f1bd83d48250134b65c77c2b6332d38d34d9016f0e8975536ad6c348a1f' + 'aedb0'} ] expected = [] for dictionary in expected_vectors: new_dict = {} for k, v in six.iteritems(dictionary): - v = v.strip() - v = v.replace(" ", "") v = int(v, 16) new_dict[k] = v expected.append(new_dict) diff --git a/tests/utils.py b/tests/utils.py index c8181585..720a9054 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -346,30 +346,30 @@ def load_fips_dsa_key_pair_vectors(vector_data): Loads data out of the FIPS DSA KeyPair vector files. """ vectors = [] - # When the flag is "on" it tells the loader to continue constructing - # dictionaries. We turn the flag to "off" during the blocks of the - # vectors of N=224 because we don't support it. - flag = "on" + # When reading_key_data is set to True it tells the loader to continue + # constructing dictionaries. We set reading_key_data to False during the + # blocks of the vectors of N=224 because we don't support it. + reading_key_data = True for line in vector_data: line = line.strip() if not line or line.startswith("#"): continue - if line.startswith("[mod = L=1024"): + elif line.startswith("[mod = L=1024"): continue - if line.startswith("[mod = L=2048, N=224"): - flag = "off" + elif line.startswith("[mod = L=2048, N=224"): + reading_key_data = False continue - if line.startswith("[mod = L=2048, N=256"): - flag = "on" + elif line.startswith("[mod = L=2048, N=256"): + reading_key_data = True continue - if line.startswith("[mod = L=3072"): + elif line.startswith("[mod = L=3072"): continue - if flag == "off": + if not reading_key_data: continue - if flag == "on": + elif reading_key_data: if line.startswith("P"): vectors.append({'p': int(line.split("=")[1], 16)}) elif line.startswith("Q"): |