Creating the rsa public key from its module and metric

I want to verify the RSA signature. I have data for verification, a signature and a public key in the form of a module and indicator. I would like to do a check using openssl. Is it possible? I know what I can use openssl rsautl -verify -in sig -inkey key.pem, but I do not know how (using openssl) to create a public key that has only a module and exponent.

Perhaps other ideas on how to verify this signature (except for writing some programs)?

+5
source share
2 answers

To generate the pbulic RS code in the PEM format to be used with openssl, you can follow these steps.

Create ASN1 Definition File

,

# Start with a SEQUENCE
asn1=SEQUENCE:pubkeyinfo

# pubkeyinfo contains an algorithm identifier and the public key wrapped
# in a BIT STRING
[pubkeyinfo]
algorithm=SEQUENCE:rsa_alg
pubkey=BITWRAP,SEQUENCE:rsapubkey

# algorithm ID for RSA is just an OID and a NULL
[rsa_alg]
algorithm=OID:rsaEncryption
parameter=NULL

# Actual public key: modulus and exponent
[rsapubkey]
n=INTEGER:0x%%MODULUS%%

e=INTEGER:0x%%EXPONENT%%

script sed

sed -i "s/%%MODULUS%%/$(xxd -ps -c 256 mymodulus.bin)/" def.asn1

, -c 256 .

.

RSA

openssl. RSA DER.

 openssl asn1parse -genconf def.asn1 -out pubkey.der -noout

PEM

 openssl rsa -in pubkey.der -inform der -pubin -out pubkey.pem

openssl dgst -verify, openssl rsautl -verify

+4

man-

 # generate private key
 openssl genrsa > key.priv

 # use it to sign something
 echo "Dirk should be given $10" | openssl rsautl -inkey key.priv -sign > msg.sig

 # create a pub key (modules, exp) from the private key
 openssl rsa -pubout < key.priv > key.pub

 # use that to verify the signature.
 openssl rsautl -in msg.sig -verify -inkey key.pub -pubin

, . - , /exp . ASN.1   .

c/java/etc. - openssl; RSA *.

-1

All Articles