Bug 1768194 - Appease lints.

MANUAL PUSH: Orange fix CLOSED TREE
This commit is contained in:
Emilio Cobos Álvarez 2022-05-18 10:59:24 +02:00
parent 6afece8ec6
commit 2d642870a6

View File

@ -7,14 +7,21 @@ from pyasn1_modules import pem
from pyasn1.type import univ from pyasn1.type import univ
import sys import sys
def public_key_to_string(file, name): def public_key_to_string(file, name):
out = "static const unsigned char " + name + "[65] = { " out = "static const unsigned char " + name + "[65] = { "
with open(file) as f: with open(file) as f:
substrate = pem.readPemFromFile(f, "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----") substrate = pem.readPemFromFile(
f, "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"
)
key = decoder.decode(substrate) key = decoder.decode(substrate)
ident = key[0][0] ident = key[0][0]
assert ident[0] == univ.ObjectIdentifier("1.2.840.10045.2.1"), "should be an ECPublicKey" assert ident[0] == univ.ObjectIdentifier(
assert ident[1] == univ.ObjectIdentifier("1.2.840.10045.3.1.7"), "should be a EcdsaP256 key" "1.2.840.10045.2.1"
), "should be an ECPublicKey"
assert ident[1] == univ.ObjectIdentifier(
"1.2.840.10045.3.1.7"
), "should be a EcdsaP256 key"
bits = key[0][1] bits = key[0][1]
assert isinstance(bits, univ.BitString), "Should be a bit string" assert isinstance(bits, univ.BitString), "Should be a bit string"
assert len(bits) == 520, "Should be 520 bits (65 bytes)" assert len(bits) == 520, "Should be 520 bits (65 bytes)"