Re: [openssl-users] Re: How to use a binary public key

2013-01-24 Thread Erwann Abalea
The 0x00 byte in the BITSTRING is the number of unused bits in the last 
octet of the encoded bit string.
See X.690 as a BER/DER reference. Document is free to download from ITU 
website.


--
Erwann ABALEA

Le 24/01/2013 19:17, kap...@mizera.cz a écrit :
I have used header from my certificate - it does contain only ASN.1 
structure data - unspecific.


The structure you can see with
openssl asn1parse -in pub-key.der -inform der

The added header are simply the first 22 bytes.
(not 21 (=18+3) - there is in correctly formated pub-key 1 byte 00h on 
begin of BIT STRING. Don't  know why.)


The BIT STRING is yours pubkey.bin.

I hope it will help :-)

--kapetr


Dne 24.1.2013 18:25, Tovey, Dwight (LaserJet RD FW Eng.) napsal(a):


On Jan 23, 2013, at 4:18 PM, kap...@mizera.cz wrote:

I have build the whole pub-key (in DER) from yours pubkey.bin by 
adding public key header - as wrote w...@omnigroup.com


If I did not make error, it could work now - try it.
It is in attachment.

openssl asn1parse -in pub-key.der -inform der -strparse 18

and you will see the same as by parsing yours pubkey.bin.

To see whole public key structure:
openssl asn1parse -in pub-key.der -inform der

--kapetr



This worked.  I translated the .der key into PEM format, which I was 
then able to load into my python script with 
M2Crypto.RSA.load_pub_key().  I could then use the resulting RSA_pub 
object to encrypt my data and send it to the device.


So, my next question is, how did you add the public key header? What 
does this header look like?  If I know that then I should be able to 
add it within my script and handle it all directly.


Thanks

Dwight Tovey
Laserjet RD Engineer
dwight.to...@hp.com
(208)396-4645



__
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org


__
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org



__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: [openssl-users] Re: How to use a binary public key

2013-01-24 Thread kapetr

Thanks for explanation.

--kapetr

Dne 24.1.2013 19:31, Erwann Abalea napsal(a):

The 0x00 byte in the BITSTRING is the number of unused bits in the last
octet of the encoded bit string.
See X.690 as a BER/DER reference. Document is free to download from ITU
website.


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org