In order to generate a RSA public key in PEM format to be used with openssl, you can follow these steps.
Create an ASN1 definition file
Modify the following template to include your modulus and exponent
# 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%%
Instead of editing, you also may want to script this using sed
sed -i "s/%%MODULUS%%/$(xxd -ps -c 256 mymodulus.bin)/" def.asn1
Note the -c 256 should be chosen according to your key length in bytes.
You can use a similar command for the exponent.
Generate your RSA key
Use the following openssl command. This will give you a DER encoded RSA key.
openssl asn1parse -genconf def.asn1 -out pubkey.der -noout
Then convert it into a PEM key
openssl rsa -in pubkey.der -inform der -pubin -out pubkey.pem
Verify using your key
You can use either openssl dgst -verify or openssl rsautl -verify