I managed to have a B4x/OpenSSL RSA encryption (see my tutorial). To open B4x to the OpenSSL/.net world (interchangable keys) I have this situation:
I have a public key (OpenSSL pkcs8) which looks like this:
Inside the header/footer there is a ASN1 formated base64 string. Parsing it with a tool shows the structure and the public key's modulus/exponent:
My problem is to convert the key data from/to little/big endian. Could someone provide some help here? I saw some examples but I don't get it. I will then post an example how to convert RSA keys (ASN1).
I have a public key (OpenSSL pkcs8) which looks like this:
B4X:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx9TXkkAnS/OvEXIhFBjY
Q0jwzpPgqAexhPjZ83cQli9WfRt228tzwjpClGmy9XndIUqbU2AA0A8MWI9VRB9D
WAVu8tomnzupWCQpouhjpjRVaH8+6wgqyPvVrNDEwA6yjz8tKQgQbrmNu38ZEhhi
X7gOUzi6uhxqVhJm7oFIEIXWBE+q07i1DIyfuNFF8XLpfVjTsyBi3MSo/TG4LrmQ
jm48Kyecn20ik7n1Al4F328gKMtwoCfGHZIVvFjuoTPH76mDyebXNkIM7Hm2kjIJ
HRPhZwvQycDeOpA8yYEsgTrPxV+B89UAXDqSbR0607KNckBipIBKUq/HoOwzV2G7
EQIDAQAB
-----END PUBLIC KEY-----
Inside the header/footer there is a ASN1 formated base64 string. Parsing it with a tool shows the structure and the public key's modulus/exponent:
B4X:
C:\xampp\apache\bin>openssl asn1parse -in PublicKey.pem
0:d=0 hl=4 l= 290 cons: SEQUENCE
4:d=1 hl=2 l= 13 cons: SEQUENCE
6:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption
17:d=2 hl=2 l= 0 prim: NULL
19:d=1 hl=4 l= 271 prim: BIT STRING
C:\xampp\apache\bin>openssl asn1parse -in publickey.pem -strparse 19
0:d=0 hl=4 l= 266 cons: SEQUENCE
4:d=1 hl=4 l= 257 prim: INTEGER :B9BD35495D097B9038321FFC17F16C4E7A9231B56606533960B080369D45E66B2FE8936AF3B32935A89787A41A53474AC48E7547DADEC8A72499CB9BC9778A23B5A8E51436A47DFD3EEF1291B5E724788A4EC624A2FC2C18A3A509E7FC351199EF82AC4D97A028352197FEA55B60EDD702AC7382E223AEB7995DF66F71027CFE99A29B8AC313F46F5EA8A78FFD16862E0FE2CAAFCDF0142D4F7B32416D1336A470B73DA7CE44836EE5CE8E8BB57B330F902C0AE105A5C80034259D64C1392261EC3446EAA50EC65C8AF372C16C285FB247796431ADC8AAFFF486A2D3D8E7A05B03338FE75C26526987BA1400F6B45AEE28FF50FBBB40AFC4D8E0E578B4E21EF7
265:d=1 hl=2 l= 3 prim: INTEGER :010001
My problem is to convert the key data from/to little/big endian. Could someone provide some help here? I saw some examples but I don't get it. I will then post an example how to convert RSA keys (ASN1).