[fsbl] add fsbl for cv181x/cv180x
Change-Id: I6809bc5016d4bc148f62be2ed3f8e928ec111f19
This commit is contained in:
29
fsbl/make_helpers/get_rsa_n.py
Executable file
29
fsbl/make_helpers/get_rsa_n.py
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
# PYTHON_ARGCOMPLETE_OK
|
||||
|
||||
import sys
|
||||
import hashlib
|
||||
import rsa
|
||||
|
||||
|
||||
def main():
|
||||
with open(sys.argv[1], "rb") as ifp:
|
||||
din = ifp.read()
|
||||
|
||||
try:
|
||||
priv = rsa.PrivateKey.load_pkcs1(din)
|
||||
except ValueError:
|
||||
priv = rsa.PrivateKey.load_pkcs1(din, format="DER")
|
||||
x = rsa.common.byte_size(priv.n)
|
||||
n = priv.n.to_bytes(x, byteorder="big")
|
||||
digest = hashlib.sha256(n).digest()
|
||||
|
||||
if sys.argv[2] == "-":
|
||||
sys.stdout.buffer.write(digest)
|
||||
else:
|
||||
with open(sys.argv[2], "wb") as ofp:
|
||||
ofp.write(digest)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user