diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 3c541d8b..25f0eef9 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -44,7 +44,7 @@ jobs: echo 'CIBW_ARCHS=x86_64 universal2' >> $GITHUB_ENV if: runner.os == 'macOS' - - uses: pypa/cibuildwheel@v2.15.0 + - uses: pypa/cibuildwheel@v2.16.5 name: Build wheels env: # cibuildwheel will build wheel once and test it for each CPython version @@ -78,17 +78,17 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-20.04, windows-latest, macos-12 ] + os: [ ubuntu-20.04, macos-12 ] arch: [ multi-arch ] # Python 2 on Windows requires manual toolchain setup (per-arch) due to newer MSVC used here exclude: - os: windows-latest arch: multi-arch - include: - - os: windows-latest - arch: x86 - - os: windows-latest - arch: x64 + #include: + # - os: windows-latest + # arch: x86 + # - os: windows-latest + # arch: x64 if: github.actor == 'Legrandin' diff --git a/lib/Crypto/PublicKey/ECC.py b/lib/Crypto/PublicKey/ECC.py index cd674f83..65917edb 100644 --- a/lib/Crypto/PublicKey/ECC.py +++ b/lib/Crypto/PublicKey/ECC.py @@ -826,18 +826,25 @@ def _import_rfc5915_der(encoded, passphrase, curve_oid=None): # publicKey [1] BIT STRING OPTIONAL # } + print("************************************************") + print("Processing %d bytes" % len(encoded)) + ec_private_key = DerSequence().decode(encoded, nr_elements=(2, 3, 4)) if ec_private_key[0] != 1: + print("Incorrect version") raise ValueError("Incorrect ECC private key version") scalar_bytes = DerOctetString().decode(ec_private_key[1]).payload + print("Payload is %d bytes" % len(scalar_bytes)) next_element = 2 # Try to decode 'parameters' if next_element < len(ec_private_key): + print("Decoding parameters") try: parameters = DerObjectId(explicit=0).decode(ec_private_key[next_element]).value + print("Parameters is", parameters) if curve_oid is not None and parameters != curve_oid: raise ValueError("Curve mismatch") curve_oid = parameters @@ -846,23 +853,28 @@ def _import_rfc5915_der(encoded, passphrase, curve_oid=None): pass if curve_oid is None: + print("No curve_oid") raise ValueError("No curve found") for curve_name, curve in _curves.items(): if curve.oid == curve_oid: break else: + print("Unknown curve_oid", curve_oid) raise UnsupportedEccFeature("Unsupported ECC curve (OID: %s)" % curve_oid) modulus_bytes = curve.p.size_in_bytes() if len(scalar_bytes) != modulus_bytes: + print("Small modulus %d bytes", len(modulus_bytes)) raise ValueError("Private key is too small") # Try to decode 'publicKey' point_x = point_y = None if next_element < len(ec_private_key): try: + print("Decode public key I") public_key_enc = DerBitString(explicit=1).decode(ec_private_key[next_element]).value + print("Decode public key II") public_key = _import_public_der(public_key_enc, curve_oid=curve_oid) point_x = public_key.pointQ.x point_y = public_key.pointQ.y @@ -870,8 +882,14 @@ def _import_rfc5915_der(encoded, passphrase, curve_oid=None): except ValueError: pass + print("Build private key") d = Integer.from_bytes(scalar_bytes) - return construct(curve=curve_name, d=d, point_x=point_x, point_y=point_y) + try: + key = construct(curve=curve_name, d=d, point_x=point_x, point_y=point_y) + except ValueError as e: + print("Failed to build", str(e)) + raise e + return key def _import_pkcs8(encoded, passphrase):