-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to generate public key base64-string? #8
Comments
Please start by enclosing code samples in markdown, so they are more easily readable; click the triple dots at the corner of this comment, and "Quote reply", to see the source of the following example:
|
Yes, (ql:quickload '(asn1 ironclad cl-tls cl-base64))
;; public-key, base64 string
(defparameter *pub-key-str*
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHdsyxT66pDG4p73yope7jxA92c0AT4qIJ/xtbBcHkFPK77upnsfDTJiVEuQDH+MiMeb+XhCLNKZGp0yaUU6GlxZdp+nLW8b7Kmijr3iepaDhcbVTsYBWchaWUXauj9Lrhz58/6AE/NF0aMolxIGpsi+ST2hSHPu3GSXMdhPCkWQIDAQAB")
;; public-key octet-vect
(defparameter *pub-key-oct*
(base64:base64-string-to-usb8-array *pub-key-str*))
(defparameter *rsa-pub-key*
(trivia:match (asn1:decode *pub-key-oct*)
((asn1:rsa-public-key-info n e)
(ironclad:make-public-key :rsa :n n :e e))))
(defparameter *n*
(ironclad:rsa-key-modulus *rsa-pub-key*))
(defparameter *e*
(ironclad:rsa-key-exponent *rsa-pub-key*))
(defparameter *generate-oct*
(cl-tls:create-asn-sequence
(list '(1 2 840 113549 1 1 1) :oid)
(list '() :null)
(list *n* :integer)
(list *e* :integer)))
(equalp *pub-key-oct* *generate-oct*)
;; -> NIL
|
Probably; however...
please link to the source from whence you took the failed test vectors; the only thing I hate worse than GitHub, is Google. |
"and result is not correct oct-vector, can you help me?" Sorry, the result is wrong, I originally wanted to express how to generate the same key(base64 string) as the original through N and E from Crypto.PublicKey import RSA
cipher = RSA.generate(1024)
public = cipher.publickey()
public_key_str = public.exportKey().decode()
print(public_key_str)
# etc:
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCbtonF8bSV1oSHsc5hPsZlVDo6
LNld7cSc5lVkwdciwXTBPjO+YqK4IXMmyYRCnycUJsQRI7ceZTNCbb0QInzFURR5
tP8E09QrmbkN4qzD7dJarJnedxgHiCkjZV/QS0GfKhp07Dh5P4/+GVbgan+9vMkF
rhgjnwmI48+eZmAXXQIDAQAB
-----END PUBLIC KEY----- I want: (equalp *pub-key-oct* *generate-oct*)
;; -> T |
Having re-read the code failing this test, I now understand what you're trying to do; not being familiar with the entire library, it'll take me a while to reply anything useful, so I recommend conducting your own study; mine could take a while. |
Hi,
if i have N and E with RSA, how to generate public key? is this library can do that?
(cl-tls:create-asn-sequence
(list '(1 2 840 113549 1 1 1) :oid)
(list n :integer)
(list e :integer))
and result is correct oct-vector, can you help me?
The text was updated successfully, but these errors were encountered: