Closed CryptoMathician closed 4 years ago
Yes, that should be possible. In rsa.js there would be a need to provide a new function
set_rsa_public_key = function(ctx,n,e)
similar to the existing
rsa_public_key = function(ctx)
Where the public key n is provided as a byte array extracted from an X.509 cert, and e=65537. Then use the ff.js function
FF.fromBytes = function(x, b)
to copy n into the public key structure.
(Note: we would regard X.509 cert processing as outside of the remit of this library)
Ok. Thank you!
Pascal
I am not sure, if that is wished, but maybe it could be useful to have getter and setter for the objects rsa_public_key
and rsa_private_key
. In the following is a suggestion how it could be done:
ctx.rsa_public_key.set(n,e);
ctx.rsa_public_key.set_e(e);
ctx.rsa_public_key.set_n(n);
ctx.rsa_public_key.get_instance(n,e);
Whereby the get_instance method creates a new rsa_public_key object and set the properties n
and e
.
It is also possible to do respectively also getter and setter for the rsa_private_key
and a get_instance method for setting the attributes manually.
What do you think about the idea?
Maybe that would be better as creating a "new" rsa_public_key object and it is possible to use the existing structure. If you want I can create a Pull Request, depends on if you think that could be useful for the library.
Yes, OK, that sounds like a good plan. Make sure and test it on a real X.509 public key!
Mike
It seems that it is possible to store a public key in that structure. I used [1] as asn1 parser and stored the bytes directly into the rsa_public_key structure with the get_instance method.
Pull Request is on the way - without the asn1 parser, only the rsa key data strucutres.
Anyway I have a question regarding the data in the array which I get back from the FF data structure. Which representation have the content of the following array?
[ 190, 66, 142, 139, 46, 151, 187, 158, 173, 174, 147, 123, ... ]
is the the 190 (from index 0) in hex or in uint or something else? I am a bit confused about the representation and wanted to know which representation are used here.
Thank you in advance!
Those are just unsigned byte values, in decimal
Thank you.
I want to create a RSA public key from a X.509 formatted RSA public key.
Is it possible to use the ASN.1/X.509 format directly to create a
rsa_public_key
? If that shouldn't be the case (it seems that it isn't the case), is it possible to set the modulus properly? I think that should be possible, but I am not sure how it will works, cause of theFF
andBIG
prototype/class which I am maybe not fully understand in detail yet (or I have missed something). Could you help me to understand how I can set the modulus in the correct way? Or better to say to create a propern
to set it correctlyIf possible to create a proper
n
it would be nice to do something like:Cause I want to create a public key with known
e
andn
.Thank you in advance!
Pascal