From 2cdfbf186950195abf35aeb4500f085f93ef0779 Mon Sep 17 00:00:00 2001 From: tuxxy Date: Mon, 15 Jan 2018 17:24:21 -0700 Subject: [PATCH 1/6] Use BN_clear_free instead of BN_free --- umbral/bignum.py | 28 ++++++++++++++-------------- umbral/point.py | 10 +++++----- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/umbral/bignum.py b/umbral/bignum.py index ea8912c..19c2165 100644 --- a/umbral/bignum.py +++ b/umbral/bignum.py @@ -26,7 +26,7 @@ class BigNum(object): order = backend._lib.BN_new() backend.openssl_assert(order != backend._ffi.NULL) - order = backend._ffi.gc(order, backend._lib.BN_free) + order = backend._ffi.gc(order, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.EC_GROUP_get_order(group, order, bn_ctx) @@ -40,7 +40,7 @@ class BigNum(object): rand_num = int.from_bytes(os.urandom(curve.key_size // 8), 'big') new_rand_bn = backend._int_to_bn(rand_num) - new_rand_bn = backend._ffi.gc(new_rand_bn, backend._lib.BN_free) + new_rand_bn = backend._ffi.gc(new_rand_bn, backend._lib.BN_clear_free) return BigNum(new_rand_bn, curve_nid, group, order) @@ -60,7 +60,7 @@ class BigNum(object): order = backend._lib.BN_new() backend.openssl_assert(order != backend._ffi.NULL) - order = backend._ffi.gc(order, backend._lib.BN_free) + order = backend._ffi.gc(order, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.EC_GROUP_get_order(group, order, bn_ctx) @@ -72,7 +72,7 @@ class BigNum(object): raise ValueError("Integer provided is not on the given curve.") bignum = backend._int_to_bn(num) - bignum = backend._ffi.gc(bignum, backend._lib.BN_free) + bignum = backend._ffi.gc(bignum, backend._lib.BN_clear_free) return BigNum(bignum, curve_nid, group, order) @@ -106,7 +106,7 @@ class BigNum(object): """ if type(other) == int: other = backend._int_to_bn(other) - other = backend._ffi.gc(other, backend._lib.BN_free) + other = backend._ffi.gc(other, backend._lib.BN_clear_free) other = BigNum(other, None, None, None) @@ -119,13 +119,13 @@ class BigNum(object): """ if type(other) == int: other = backend._int_to_bn(other) - other = backend._ffi.gc(other, backend._lib.BN_free) + other = backend._ffi.gc(other, backend._lib.BN_clear_free) other = BigNum(other, None, None, None) power = backend._lib.BN_new() backend.openssl_assert(power != backend._ffi.NULL) - power = backend._ffi.gc(power, backend._lib.BN_free) + power = backend._ffi.gc(power, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.BN_mod_exp( @@ -141,7 +141,7 @@ class BigNum(object): """ product = backend._lib.BN_new() backend.openssl_assert(product != backend._ffi.NULL) - product = backend._ffi.gc(product, backend._lib.BN_free) + product = backend._ffi.gc(product, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.BN_mod_mul( @@ -157,7 +157,7 @@ class BigNum(object): """ product = backend._lib.BN_new() backend.openssl_assert(product != backend._ffi.NULL) - product = backend._ffi.gc(product, backend._lib.BN_free) + product = backend._ffi.gc(product, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: inv_other = backend._lib.BN_mod_inverse( @@ -178,7 +178,7 @@ class BigNum(object): """ sum = backend._lib.BN_new() backend.openssl_assert(sum != backend._ffi.NULL) - sum = backend._ffi.gc(sum, backend._lib.BN_free) + sum = backend._ffi.gc(sum, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.BN_mod_add( @@ -194,7 +194,7 @@ class BigNum(object): """ diff = backend._lib.BN_new() backend.openssl_assert(diff != backend._ffi.NULL) - diff = backend._ffi.gc(diff, backend._lib.BN_free) + diff = backend._ffi.gc(diff, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.BN_mod_sub( @@ -213,7 +213,7 @@ class BigNum(object): backend._ffi.NULL, self.bignum, self.order, bn_ctx ) backend.openssl_assert(inv != backend._ffi.NULL) - inv = backend._ffi.gc(inv, backend._lib.BN_free) + inv = backend._ffi.gc(inv, backend._lib.BN_clear_free) return BigNum(inv, self.curve_nid, self.group, self.order) @@ -223,13 +223,13 @@ class BigNum(object): """ if type(other) == int: other = backend._int_to_bn(other) - other = backend._ffi.gc(other, backend._lib.BN_free) + other = backend._ffi.gc(other, backend._lib.BN_clear_free) other = BigNum(other, None, None, None) rem = backend._lib.BN_new() backend.openssl_assert(rem != backend._ffi.NULL) - rem = backend._ffi.gc(rem, backend._lib.BN_free) + rem = backend._ffi.gc(rem, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.BN_nnmod( diff --git a/umbral/point.py b/umbral/point.py index 77ec3ad..b3052f0 100644 --- a/umbral/point.py +++ b/umbral/point.py @@ -55,11 +55,11 @@ class Point(object): affine_x, affine_y = coords if type(affine_x) == int: affine_x = backend._int_to_bn(affine_x) - affine_x = backend._ffi.gc(affine_x, backend._lib.BN_free) + affine_x = backend._ffi.gc(affine_x, backend._lib.BN_clear_free) if type(affine_y) == int: affine_y = backend._int_to_bn(affine_y) - affine_y = backend._ffi.gc(affine_y, backend._lib.BN_free) + affine_y = backend._ffi.gc(affine_y, backend._lib.BN_clear_free) group = backend._lib.EC_GROUP_new_by_curve_name(curve_nid) backend.openssl_assert(group != backend._ffi.NULL) @@ -82,11 +82,11 @@ class Point(object): """ affine_x = backend._lib.BN_new() backend.openssl_assert(affine_x != backend._ffi.NULL) - affine_x = backend._ffi.gc(affine_x, backend._lib.BN_free) + affine_x = backend._ffi.gc(affine_x, backend._lib.BN_clear_free) affine_y = backend._lib.BN_new() backend.openssl_assert(affine_y != backend._ffi.NULL) - affine_y = backend._ffi.gc(affine_y, backend._lib.BN_free) + affine_y = backend._ffi.gc(affine_y, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.EC_POINT_get_affine_coordinates_GFp( @@ -194,7 +194,7 @@ class Point(object): order = backend._lib.BN_new() backend.openssl_assert(order != backend._ffi.NULL) - order = backend._ffi.gc(order, backend._lib.BN_free) + order = backend._ffi.gc(order, backend._lib.BN_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.EC_GROUP_get_order(group, order, bn_ctx) From 8555d36f9b49a4d5f20c2bfc73c1d2bc8328557d Mon Sep 17 00:00:00 2001 From: tuxxy Date: Mon, 15 Jan 2018 17:24:38 -0700 Subject: [PATCH 2/6] Use EC_POINT_clear_free instead of EC_POINT_free --- umbral/point.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/umbral/point.py b/umbral/point.py index b3052f0..58b955d 100644 --- a/umbral/point.py +++ b/umbral/point.py @@ -28,7 +28,8 @@ class Point(object): rand_point = backend._lib.EC_POINT_new(group) backend.openssl_assert(rand_point != backend._ffi.NULL) - rand_point = backend._ffi.gc(rand_point, backend._lib.EC_POINT_free) + rand_point = backend._ffi.gc(rand_point, + backend._lib.EC_POINT_clear_free) rand_bn = BigNum.gen_rand(curve).bignum @@ -117,7 +118,8 @@ class Point(object): ec_point = backend._lib.EC_POINT_new(affine_x.group) backend.openssl_assert(ec_point != backend._ffi.NULL) - ec_point = backend._ffi.gc(ec_point, backend._lib.EC_POINT_free) + ec_point = backend._ffi.gc(ec_point, + backend._lib.EC_POINT_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.EC_POINT_set_compressed_coordinates_GFp( @@ -221,7 +223,7 @@ class Point(object): """ prod = backend._lib.EC_POINT_new(self.group) backend.openssl_assert(prod != backend._ffi.NULL) - prod = backend._ffi.gc(prod, backend._lib.EC_POINT_free) + prod = backend._ffi.gc(prod, backend._lib.EC_POINT_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.EC_POINT_mul( @@ -238,7 +240,7 @@ class Point(object): """ sum = backend._lib.EC_POINT_new(self.group) backend.openssl_assert(sum != backend._ffi.NULL) - sum = backend._ffi.gc(sum, backend._lib.EC_POINT_free) + sum = backend._ffi.gc(sum, backend._lib.EC_POINT_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.EC_POINT_add( @@ -260,7 +262,7 @@ class Point(object): """ inv = backend._lib.EC_POINT_dup(self.ec_point, self.group) backend.openssl_assert(inv != backend._ffi.NULL) - inv = backend._ffi.gc(inv, backend._lib.EC_POINT_free) + inv = backend._ffi.gc(inv, backend._lib.EC_POINT_clear_free) with backend._tmp_bn_ctx() as bn_ctx: res = backend._lib.EC_POINT_invert( From fe69a451b32ea1ff5dc44748364cbe9b0dbe604a Mon Sep 17 00:00:00 2001 From: tuxxy Date: Mon, 19 Mar 2018 13:10:44 -0600 Subject: [PATCH 3/6] Upgrade to cryptography.io 2.2 --- Pipfile | 3 +- Pipfile.lock | 224 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 149 insertions(+), 78 deletions(-) diff --git a/Pipfile b/Pipfile index dafe26b..ddb5699 100644 --- a/Pipfile +++ b/Pipfile @@ -7,7 +7,7 @@ name = "pypi" [packages] -cryptography = "*" +cryptography = "==2.2" pynacl = "*" @@ -22,3 +22,4 @@ pytest-mock = "*" codecov = "*" sphinx = "*" sphinx-autobuild = "*" +cryptography = "==2.2" diff --git a/Pipfile.lock b/Pipfile.lock index 5a28b9f..b6468fb 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,20 +1,20 @@ { "_meta": { "hash": { - "sha256": "33b7467bbee46dd21209de1da9b4a785b4619d0a115054292cb0a2a4fd813621" + "sha256": "d90f90e9d0429f7ce6c908ef78c745c01f12bf93c160270188037d6c8481df5b" }, "host-environment-markers": { "implementation_name": "cpython", - "implementation_version": "3.6.3", + "implementation_version": "3.6.2", "os_name": "posix", "platform_machine": "x86_64", "platform_python_implementation": "CPython", - "platform_release": "4.13.0-32-generic", - "platform_system": "Linux", - "platform_version": "#35-Ubuntu SMP Thu Jan 25 09:13:46 UTC 2018", - "python_full_version": "3.6.3", + "platform_release": "17.4.0", + "platform_system": "Darwin", + "platform_version": "Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64", + "python_full_version": "3.6.2", "python_version": "3.6", - "sys_platform": "linux" + "sys_platform": "darwin" }, "pipfile-spec": 6, "requires": {}, @@ -36,64 +36,58 @@ }, "cffi": { "hashes": [ - "sha256:5d0d7023b72794ea847725680e2156d1d01bc698a9007fccce46d03c904fe093", - "sha256:86903c0afab4a3390170aca61f753f5adad8ffff947030719ee44dedc5b68403", - "sha256:7d35678a54da0d3f1bc30e3a58a232043753d57c691875b5a75e4e062793bc9a", - "sha256:824cac33906be5c8e976f0d950924d88ec058989ef9cd2f77f5cd53cec417635", - "sha256:6ca52651f6bd4b8647cb7dee15c82619de3e13490f8e0bc0620830a2245b51d1", - "sha256:a183959a4b1e01d6172aeed356e2523ec8682596075aa6cf0003fe08da959a49", - "sha256:9532c5bc0108bd0fe43c0eb3faa2ef98a2db60fc0d4019f106b88d46803dd663", - "sha256:96652215ef328262b5f1d5647632bd342ac6b31dfbc495b21f1ab27cb06d621d", - "sha256:6c99d19225e3135f6190a3bfce2a614cae8eaa5dcaf9e0705d4ccb79a3959a3f", - "sha256:12cbf4c04c1ad07124bfc9e928c01e282feac9ec7dd72a18042d4fc56456289a", - "sha256:69c37089ccf10692361c8d14dbf4138b00b46741ffe9628755054499f06ed548", - "sha256:b8d1454ef627098dc76ccfd6211a08065e6f84efe3754d8d112049fec3768e71", - "sha256:cd13f347235410c592f6e36395ee1c136a64b66534f10173bfa4df1dc88f47d0", - "sha256:0640f12f04f257c4467075a804a4920a5d07ef91e11c525fc65d715c08231c81", - "sha256:89a8d05b96bdeca8fdc89c5fa9469a357d30f6c066262e92c0c8d2e4d3c53cae", - "sha256:a67c430a9bde73ae85b0c885fcf41b556760e42ea74c16dc70431a349989b448", - "sha256:7a831170b621e98f45ed1d5758325be19619a593924127a0a47af9a72a117319", - "sha256:796d0379102e6da5215acfcd20e8e69cca9d97309215b4ce088fe175b1c2f586", - "sha256:0fe3b3d571543a4065059d1d3d6d39f4ca6da0f2207ad13547094522e32ead46", - "sha256:678135090c311780382b1dd3f828f715583ea8a69687ed053c047d3cec6625d6", - "sha256:f4992cd7b4c867f453d44c213ee29e8fd484cf81cfece4b6e836d0982b6fa1cf", - "sha256:6d191fb20138fe1948727b20e7b96582b7b7e676135eabf72d910e10bf7bfa65", - "sha256:ec208ca16e57904dd7f4c7568665f80b1f7eb7e3214be014560c28def219060d", - "sha256:b3653644d6411bf4bd64c1f2ca3cb1b093f98c68439ade5cef328609bbfabf8c", - "sha256:f4719d0bafc5f0a67b2ec432086d40f653840698d41fa6e9afa679403dea9d78", - "sha256:87f837459c3c78d75cb4f5aadf08a7104db15e8c7618a5c732e60f252279c7a6", - "sha256:df9083a992b17a28cd4251a3f5c879e0198bb26c9e808c4647e0a18739f1d11d" + "sha256:1b0493c091a1898f1136e3f4f991a784437fac3673780ff9de3bcf46c80b6b50", + "sha256:87f37fe5130574ff76c17cab61e7d2538a16f843bb7bca8ebbc4b12de3078596", + "sha256:1553d1e99f035ace1c0544050622b7bc963374a00c467edafac50ad7bd276aef", + "sha256:151b7eefd035c56b2b2e1eb9963c90c6302dc15fbd8c1c0a83a163ff2c7d7743", + "sha256:edabd457cd23a02965166026fd9bfd196f4324fe6032e866d0f3bd0301cd486f", + "sha256:ba5e697569f84b13640c9e193170e89c13c6244c24400fc57e88724ef610cd31", + "sha256:79f9b6f7c46ae1f8ded75f68cf8ad50e5729ed4d590c74840471fc2823457d04", + "sha256:b0f7d4a3df8f06cf49f9f121bead236e328074de6449866515cea4907bbc63d6", + "sha256:4c91af6e967c2015729d3e69c2e51d92f9898c330d6a851bf8f121236f3defd3", + "sha256:7a33145e04d44ce95bcd71e522b478d282ad0eafaf34fe1ec5bbd73e662f22b6", + "sha256:95d5251e4b5ca00061f9d9f3d6fe537247e145a8524ae9fd30a2f8fbce993b5b", + "sha256:b75110fb114fa366b29a027d0c9be3709579602ae111ff61674d28c93606acca", + "sha256:ae5e35a2c189d397b91034642cb0eab0e346f776ec2eb44a49a459e6615d6e2e", + "sha256:fdf1c1dc5bafc32bc5d08b054f94d659422b05aba244d6be4ddc1c72d9aa70fb", + "sha256:9d1d3e63a4afdc29bd76ce6aa9d58c771cd1599fbba8cf5057e7860b203710dd", + "sha256:be2a9b390f77fd7676d80bc3cdc4f8edb940d8c198ed2d8c0be1319018c778e1", + "sha256:ed01918d545a38998bfa5902c7c00e0fee90e957ce036a4000a88e3fe2264917", + "sha256:857959354ae3a6fa3da6651b966d13b0a8bed6bbc87a0de7b38a549db1d2a359", + "sha256:2ba8a45822b7aee805ab49abfe7eec16b90587f7f26df20c71dd89e45a97076f", + "sha256:a36c5c154f9d42ec176e6e620cb0dd275744aa1d804786a71ac37dc3661a5e95", + "sha256:e55e22ac0a30023426564b1059b035973ec82186ddddbac867078435801c7801", + "sha256:3eb6434197633b7748cea30bf0ba9f66727cdce45117a712b29a443943733257", + "sha256:ecbb7b01409e9b782df5ded849c178a0aa7c906cf8c5a67368047daab282b184", + "sha256:770f3782b31f50b68627e22f91cb182c48c47c02eb405fd689472aa7b7aa16dc", + "sha256:d5d8555d9bfc3f02385c1c37e9f998e2011f0db4f90e250e5bc0c0a85a813085", + "sha256:3c85641778460581c42924384f5e68076d724ceac0f267d66c757f7535069c93", + "sha256:e90f17980e6ab0f3c2f3730e56d1fe9bcba1891eeea58966e89d352492cc74f4" ], "markers": "platform_python_implementation != 'PyPy'", - "version": "==1.11.4" + "version": "==1.11.5" }, "cryptography": { "hashes": [ - "sha256:69285f5615507b6625f89ea1048addd1d9218585fb886eb90bdebb1d2b2d26f5", - "sha256:6cb1224da391fa90f1be524eafb375b62baf8d3df9690b32e8cc475ccfccee5e", - "sha256:4f385ee7d39ee1ed74f1d6b1da03d0734ea82855a7b28a9e6e88c4091bc58664", - "sha256:a5f2c681fd040ed648513939a1dd2242af19bd5e9e79e53b6dcfa33bdae61217", - "sha256:fc2208d95d9ecc8032f5e38330d5ace2e3b0b998e42b08c30c35b2ab3a4a3bc8", - "sha256:0d39a93cf25edeae1f796bbc5960e587f34513a852564f6345ea4491a86c5997", - "sha256:41f94194ae78f83fd94ca94fb8ad65f92210a76a2421169ffa5c33c3ec7605f4", - "sha256:7a2409f1564c84bcf2563d379c9b6148c5bc6b0ae46e109f6a7b4bebadf551df", - "sha256:55555d784cfdf9033e81f044c0df04babed2aa141213765d960d233b0139e353", - "sha256:9a47a80f65f4feaaf8415a40c339806c7d7d867152ddccc6ca87f707c8b7b565", - "sha256:6fb22f63e17813f3d1d8e30dd1e249e2c34233ba1d3de977fd31cb5db764c7d0", - "sha256:ee245f185fae723133511e2450be08a66c2eebb53ad27c0c19b228029f4748a5", - "sha256:9a2945efcff84830c8e237ab037d0269380d75d400a89cc9e5628e52647e21be", - "sha256:2cfcee8829c5dec55597826d52c26bc26e7ce39adb4771584459d0636b0b7108", - "sha256:33b564196dcd563e309a0b07444e31611368afe3a3822160c046f5e4c3b5cdd7", - "sha256:18d0b0fc21f39b35ea469a82584f55eeecec1f65a92d85af712c425bdef627b3", - "sha256:d18df9cf3f3212df28d445ea82ce702c4d7a35817ef7a38ee38879ffa8f7e857", - "sha256:b984523d28737e373c7c35c8b6db6001537609d47534892de189bebebaa42a47", - "sha256:27a208b9600166976182351174948e128818e7fc95cbdba18143f3106a211546", - "sha256:28e4e9a97713aa47b5ef9c5003def2eb58aec89781ef3ef82b1c2916a8b0639b", - "sha256:a3c180d12ffb1d8ee5b33a514a5bcb2a9cc06cc89aa74038015591170c82f55d", - "sha256:8487524a1212223ca6dc7e2c8913024618f7ff29855c98869088e3818d5f6733", - "sha256:e4d967371c5b6b2e67855066471d844c5d52d210c36c28d49a8507b96e2c5291" + "sha256:f1d2d8e808523bac32737d167f3b7370429a9e575d156e887779310e57e41b5d", + "sha256:f76e27b5a57337352b59b79a342264b9a8557dc11174e6ec222d0b5e266b132f", + "sha256:aead0332e00ae18045f3d4a8eea3891be095aa5bb3a74ea0affa49fe80c40ecd", + "sha256:ee37235d837c9b6bdd921d396017b65df67c4c16befc1772be5266304fdaf427", + "sha256:cc5a53061d65bc8f80b08645b32c814071630e763a897b0db72fbb0e170fc93f", + "sha256:a0d0f1a7aebeb9a4145ee09a4667a7510caf97bd127c4b5d6332d013050a7567", + "sha256:527c096af06aa0620d3d361b17e6d314e9d4800ce53c2ad841d9fe5a82488acd", + "sha256:2ec7cc10a65b6ea9efd46e9c6f247e01c707c92074d2ba0be5c2641defe858f7", + "sha256:0e426fcb6e6f9100b3e3373458888cc6deb5934e6c4a26996ad720de35bce276", + "sha256:b323325ea2dcacfdf3ff8f82a1069ab9e65353cc433625c4ebe54ed70ced4137", + "sha256:252185cbe85c057796458f365425d45d7cd7f748ca53dbc906359a22e156cfd2", + "sha256:8c0f5b4001fcaf742f9d74b483249d4675de2f837146baf8f2e4a7999993fcb4", + "sha256:0f11c46e22bb4c2f6811ae408fb72e262116e864cf1e75d9503bd6a5ced04fb4", + "sha256:064e820797b6992104041e74a32f912b4e4279da4e7821daa31b580de1fa910c", + "sha256:30427c764aa0fcc6983af78bcbd540e10a87a094cbe428006329c6666ce00db8", + "sha256:0222f19fa29c609b4be4bc260db6ab9bfabca1b2626ebf97875cca21ac60d968", + "sha256:f5a0279e362c37e2150a32fe35ec20226e9237b6c9927fce8d53ef8e49e64f48" ], - "version": "==2.1.4" + "version": "==2.2" }, "idna": { "hashes": [ @@ -152,6 +146,14 @@ ], "version": "==0.7.10" }, + "appnope": { + "hashes": [ + "sha256:5b26757dc6f79a3b7dc9fab95359328d5747fcb2409d331ea66d0272b90ab2a0", + "sha256:8b995ffe925347a2138d7ac0fe77155e4311a0ea6d6da4f5128fe4b3cbe5ed71" + ], + "markers": "sys_platform == 'darwin'", + "version": "==0.1.0" + }, "argh": { "hashes": [ "sha256:a9b3aaa1904eeb78e32394cd46c6f37ac0fb4af6dc488daa58971bdc7d7fcaf3", @@ -159,6 +161,13 @@ ], "version": "==0.26.2" }, + "asn1crypto": { + "hashes": [ + "sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87", + "sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49" + ], + "version": "==0.24.0" + }, "attrs": { "hashes": [ "sha256:a17a9573a6f475c99b551c0e0a812707ddda1ec9653bed04c13841404ed6f450", @@ -180,6 +189,39 @@ ], "version": "==2018.1.18" }, + "cffi": { + "hashes": [ + "sha256:1b0493c091a1898f1136e3f4f991a784437fac3673780ff9de3bcf46c80b6b50", + "sha256:87f37fe5130574ff76c17cab61e7d2538a16f843bb7bca8ebbc4b12de3078596", + "sha256:1553d1e99f035ace1c0544050622b7bc963374a00c467edafac50ad7bd276aef", + "sha256:151b7eefd035c56b2b2e1eb9963c90c6302dc15fbd8c1c0a83a163ff2c7d7743", + "sha256:edabd457cd23a02965166026fd9bfd196f4324fe6032e866d0f3bd0301cd486f", + "sha256:ba5e697569f84b13640c9e193170e89c13c6244c24400fc57e88724ef610cd31", + "sha256:79f9b6f7c46ae1f8ded75f68cf8ad50e5729ed4d590c74840471fc2823457d04", + "sha256:b0f7d4a3df8f06cf49f9f121bead236e328074de6449866515cea4907bbc63d6", + "sha256:4c91af6e967c2015729d3e69c2e51d92f9898c330d6a851bf8f121236f3defd3", + "sha256:7a33145e04d44ce95bcd71e522b478d282ad0eafaf34fe1ec5bbd73e662f22b6", + "sha256:95d5251e4b5ca00061f9d9f3d6fe537247e145a8524ae9fd30a2f8fbce993b5b", + "sha256:b75110fb114fa366b29a027d0c9be3709579602ae111ff61674d28c93606acca", + "sha256:ae5e35a2c189d397b91034642cb0eab0e346f776ec2eb44a49a459e6615d6e2e", + "sha256:fdf1c1dc5bafc32bc5d08b054f94d659422b05aba244d6be4ddc1c72d9aa70fb", + "sha256:9d1d3e63a4afdc29bd76ce6aa9d58c771cd1599fbba8cf5057e7860b203710dd", + "sha256:be2a9b390f77fd7676d80bc3cdc4f8edb940d8c198ed2d8c0be1319018c778e1", + "sha256:ed01918d545a38998bfa5902c7c00e0fee90e957ce036a4000a88e3fe2264917", + "sha256:857959354ae3a6fa3da6651b966d13b0a8bed6bbc87a0de7b38a549db1d2a359", + "sha256:2ba8a45822b7aee805ab49abfe7eec16b90587f7f26df20c71dd89e45a97076f", + "sha256:a36c5c154f9d42ec176e6e620cb0dd275744aa1d804786a71ac37dc3661a5e95", + "sha256:e55e22ac0a30023426564b1059b035973ec82186ddddbac867078435801c7801", + "sha256:3eb6434197633b7748cea30bf0ba9f66727cdce45117a712b29a443943733257", + "sha256:ecbb7b01409e9b782df5ded849c178a0aa7c906cf8c5a67368047daab282b184", + "sha256:770f3782b31f50b68627e22f91cb182c48c47c02eb405fd689472aa7b7aa16dc", + "sha256:d5d8555d9bfc3f02385c1c37e9f998e2011f0db4f90e250e5bc0c0a85a813085", + "sha256:3c85641778460581c42924384f5e68076d724ceac0f267d66c757f7535069c93", + "sha256:e90f17980e6ab0f3c2f3730e56d1fe9bcba1891eeea58966e89d352492cc74f4" + ], + "markers": "platform_python_implementation != 'PyPy'", + "version": "==1.11.5" + }, "chardet": { "hashes": [ "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691", @@ -235,6 +277,28 @@ ], "version": "==4.5.1" }, + "cryptography": { + "hashes": [ + "sha256:f1d2d8e808523bac32737d167f3b7370429a9e575d156e887779310e57e41b5d", + "sha256:f76e27b5a57337352b59b79a342264b9a8557dc11174e6ec222d0b5e266b132f", + "sha256:aead0332e00ae18045f3d4a8eea3891be095aa5bb3a74ea0affa49fe80c40ecd", + "sha256:ee37235d837c9b6bdd921d396017b65df67c4c16befc1772be5266304fdaf427", + "sha256:cc5a53061d65bc8f80b08645b32c814071630e763a897b0db72fbb0e170fc93f", + "sha256:a0d0f1a7aebeb9a4145ee09a4667a7510caf97bd127c4b5d6332d013050a7567", + "sha256:527c096af06aa0620d3d361b17e6d314e9d4800ce53c2ad841d9fe5a82488acd", + "sha256:2ec7cc10a65b6ea9efd46e9c6f247e01c707c92074d2ba0be5c2641defe858f7", + "sha256:0e426fcb6e6f9100b3e3373458888cc6deb5934e6c4a26996ad720de35bce276", + "sha256:b323325ea2dcacfdf3ff8f82a1069ab9e65353cc433625c4ebe54ed70ced4137", + "sha256:252185cbe85c057796458f365425d45d7cd7f748ca53dbc906359a22e156cfd2", + "sha256:8c0f5b4001fcaf742f9d74b483249d4675de2f837146baf8f2e4a7999993fcb4", + "sha256:0f11c46e22bb4c2f6811ae408fb72e262116e864cf1e75d9503bd6a5ced04fb4", + "sha256:064e820797b6992104041e74a32f912b4e4279da4e7821daa31b580de1fa910c", + "sha256:30427c764aa0fcc6983af78bcbd540e10a87a094cbe428006329c6666ce00db8", + "sha256:0222f19fa29c609b4be4bc260db6ab9bfabca1b2626ebf97875cca21ac60d968", + "sha256:f5a0279e362c37e2150a32fe35ec20226e9237b6c9927fce8d53ef8e49e64f48" + ], + "version": "==2.2" + }, "decorator": { "hashes": [ "sha256:94d1d8905f5010d74bbbd86c30471255661a14187c45f8d7f3e5aa8540fdb2e5", @@ -313,10 +377,10 @@ }, "packaging": { "hashes": [ - "sha256:99276dc6e3a7851f32027a68f1095cd3f77c148091b092ea867a351811cfe388", - "sha256:5d50835fdf0a7edf0b55e311b7c887786504efea1177abd7e69329a8e5ea619e" + "sha256:e9215d2d2535d3ae866c3d6efc77d5b24a0192cce0ff20e42896cc0664f889c0", + "sha256:f019b770dd64e585a99714f1fd5e01c7a8f11b45635aa953fd41c689a657375b" ], - "version": "==16.8" + "version": "==17.1" }, "parso": { "hashes": [ @@ -386,6 +450,12 @@ ], "version": "==1.5.2" }, + "pycparser": { + "hashes": [ + "sha256:99a8ca03e29851d96616ad0404b4aad7d9ee16f25c9f9708a11faf2810f7b226" + ], + "version": "==2.18" + }, "pygments": { "hashes": [ "sha256:78f3f434bcc5d6ee09020f92ba487f95ba50f1e3ef83ae96b9d5ffa1bab25c5d", @@ -407,10 +477,10 @@ }, "pytest": { "hashes": [ - "sha256:95fa025cd6deb5d937e04e368a00552332b58cae23f63b76c8c540ff1733ab6d", - "sha256:6074ea3b9c999bd6d0df5fa9d12dd95ccd23550df2a582f5f5b848331d2e82ca" + "sha256:062027955bccbc04d2fcd5d79690947e018ba31abe4c90b2c6721abec734261b", + "sha256:117bad36c1a787e1a8a659df35de53ba05f9f3398fb9e4ac17e80ad5903eb8c5" ], - "version": "==3.4.0" + "version": "==3.4.2" }, "pytest-cov": { "hashes": [ @@ -421,10 +491,10 @@ }, "pytest-mock": { "hashes": [ - "sha256:7ed6e7e8c636fd320927c5d73aedb77ac2eeb37196c3410e6176b7c92fdf2f69", - "sha256:920d1167af5c2c2ad3fa0717d0c6c52e97e97810160c15721ac895cac53abb1c" + "sha256:03a2fea79d0a83a8de2e77e92afe5f0a5ca99a58cc68f843f9a74de34800a943", + "sha256:b879dff61e31fcd4727c227c182f15f222a155293cc64ed5a02d55e0020cf949" ], - "version": "==1.6.3" + "version": "==1.7.1" }, "pytz": { "hashes": [ @@ -488,10 +558,10 @@ }, "sphinx": { "hashes": [ - "sha256:a0b16810d1d1413dec006ce2b08b5c895b2aaa7dce18d579d3ef79c03d461b22", - "sha256:278b7923f3f4ed2a1d1359f0ae94d89ac90ddd4189e8362f4b4d3baa2afe6b4a" + "sha256:41ae26acc6130ccf6ed47e5cca73742b80d55a134f0ab897c479bba8d3640b8e", + "sha256:da987de5fcca21a4acc7f67a86a363039e67ac3e8827161e61b91deb131c0ee8" ], - "version": "==1.7.0" + "version": "==1.7.1" }, "sphinx-autobuild": { "hashes": [ @@ -509,13 +579,13 @@ }, "tornado": { "hashes": [ - "sha256:92b7ca81e18ba9ec3031a7ee73d4577ac21d41a0c9b775a9182f43301c3b5f8e", - "sha256:b36298e9f63f18cad97378db2222c0e0ca6a55f6304e605515e05a25483ed51a", - "sha256:ab587996fe6fb9ce65abfda440f9b61e4f9f2cf921967723540679176915e4c3", - "sha256:5ef073ac6180038ccf99411fe05ae9aafb675952a2c8db60592d5daf8401f803", - "sha256:6d14e47eab0e15799cf3cdcc86b0b98279da68522caace2bd7ce644287685f0a" + "sha256:69194436190b777abf0b631a692b0b29ba4157d18eeee07327b486e033b944dc", + "sha256:186ba4f280429a24120f329c7c08ea91818ff6bf47ed2ccb66f8f460698fc4ed", + "sha256:b5bf7407f88327b80e666dabf91a1e7beb11236855a5c65ba5cf0e9e25ae296b", + "sha256:4d192236a9ffee54cb0032f22a8a0cfa64258872f1d83d71f3356681f69a37be", + "sha256:3e9a2333362d3dad7876d902595b64aea1a2f91d0df13191ea1f8bca5a447771" ], - "version": "==4.5.3" + "version": "==5.0.1" }, "traitlets": { "hashes": [ From 6e687bbccb8bbcede0476066f37c9624c5703640 Mon Sep 17 00:00:00 2001 From: tuxxy Date: Mon, 19 Mar 2018 13:22:41 -0600 Subject: [PATCH 4/6] Generate a random BigNum within the order of the curve using BN_rand_range --- umbral/bignum.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/umbral/bignum.py b/umbral/bignum.py index 767567e..1ba9b46 100644 --- a/umbral/bignum.py +++ b/umbral/bignum.py @@ -39,17 +39,13 @@ class BigNum(object): res = backend._lib.EC_GROUP_get_order(group, order, bn_ctx) backend.openssl_assert(res == 1) - order_int = backend._bn_to_int(order) - - # Generate random number on curve - key_size = get_curve_keysize_bytes(curve) - rand_num = int.from_bytes(os.urandom(key_size), 'big') - while rand_num >= order_int or rand_num <= 0: - rand_num = int.from_bytes(os.urandom(key_size), 'big') - - new_rand_bn = backend._int_to_bn(rand_num) + new_rand_bn = backend._lib.BN_new() + backend.openssl_assert(new_rand_bn != backend._ffi.NULL) new_rand_bn = backend._ffi.gc(new_rand_bn, backend._lib.BN_clear_free) + rand_res = backend._lib.BN_rand_range(new_rand_bn, order) + backend.openssl_assert(rand_res == 1) + return cls(new_rand_bn, curve_nid, group, order) @classmethod From 6afa11717bda50be24db228a4a8630bf705a2832 Mon Sep 17 00:00:00 2001 From: tuxxy Date: Mon, 19 Mar 2018 23:07:11 -0600 Subject: [PATCH 5/6] Use >=2.2 for cryptography.io --- Pipfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pipfile b/Pipfile index ddb5699..5e4cba7 100644 --- a/Pipfile +++ b/Pipfile @@ -7,7 +7,7 @@ name = "pypi" [packages] -cryptography = "==2.2" +cryptography = ">=2.2" pynacl = "*" @@ -22,4 +22,4 @@ pytest-mock = "*" codecov = "*" sphinx = "*" sphinx-autobuild = "*" -cryptography = "==2.2" +cryptography = ">=2.2" From c486a8a6a2996001cf3b13dba0873de3d4a9a663 Mon Sep 17 00:00:00 2001 From: dongsam Date: Wed, 21 Mar 2018 14:45:27 +0900 Subject: [PATCH 6/6] Fix broken Example code on READEME --- README.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index 3e432f2..3962276 100644 --- a/README.rst +++ b/README.rst @@ -22,19 +22,19 @@ extending the traditional cryptological narrative of "Alice and Bob" by introduc .. code-block:: python - from umbral import umbral, keys + from umbral import pre, keys # Generate umbral keys for Alice. alices_private_key = keys.UmbralPrivateKey.gen_key() - alices_public_key = private_key.get_pubkey() + alices_public_key = alices_private_key.get_pubkey() # Encrypt data with Alice's public key. plaintext = b'Proxy Re-encryption is cool!' - ciphertext, capsule = umbral.encrypt(alices_public_key, plaintext) + ciphertext, capsule = pre.encrypt(alices_public_key, plaintext) # Decrypt data with Alice's private key. - cleartext = umbral.decrypt(capsule, alices_private_key, - ciphertext, alices_public_key) + cleartext = pre.decrypt(capsule, alices_private_key, + ciphertext, alices_public_key) **Fragmentation** @@ -42,10 +42,10 @@ extending the traditional cryptological narrative of "Alice and Bob" by introduc # Generate umbral keys for Bob. bobs_private_key = keys.UmbralPrivateKey.gen_key() - bobs_public_key = private_key.get_pubkey() + bobs_public_key = bobs_private_key.get_pubkey() # Alice generates split re-encryption keys for Bob with "M of N". - kfrags, _ = umbral.split_rekey(alices_private_key, bobs_public_key, 10, 20) + kfrags = pre.split_rekey(alices_private_key, bobs_public_key, 10, 20) **Re-encryption** @@ -55,12 +55,12 @@ extending the traditional cryptological narrative of "Alice and Bob" by introduc # Ursula re-encrypts the capsule to obtain a cfrag. # Bob attaches the cfrags to the capsule. for kfrag in kfrags: - cfrag = umbral.reencrypt(kfrag, capsule) + cfrag = pre.reencrypt(kfrag, capsule) capsule.attach_cfrag(cfrag) # Bob activates and opens the capsule. - cleartext = umbral.decrypt(capsule, bobs_private_key, - ciphertext, alices_public_key) + cleartext = pre.decrypt(capsule, bobs_private_key, + ciphertext, alices_public_key) Features