Hi,
When I run openssl rsa to display my public key info. I see this below. How
do I convert this output to a byte array? What is this output? Is it ascii
or base64?


00,ac,80,e7,da,fb,6b,82,d2,01,ac,cf,74,fa,dc,

66,44,24,5e,04,01,88,35,5f,6f,39,85,1d,7c,e0

81,d8,b1,d7,87,8f,f7,a9,01,91,67,ed,2d,4b,a0

9c,d6,a0,7c,98,43,66,e6,0a,8c,3f,22,e4,89,96

d1,74,0b,b0,a9,5f,ee,05,03,43,90,ef,6b,9b,be

bb,74,19,40,55,30,e8,97,24,db,b8,36,e1,2d,64

fd,3c,bf,c6,48,8e,e9,71,d7,4e,6b,95,08,a9,ac

ce,8d,e3,a2,73,56,93,46,0c,b4,e3,14,32,94,a5

01,5b,26,19,55,ae,79,5d,77,7f,45,a5,57,b7,43

b6,16,b3,d3,75,af,62,c3,64,d8,b0,70,6b,b1,22

33,4e,be,32,04,e7,43,0e,d2,b7,eb,32,bc,c4,0c

3c,fe,2a,17,cc,53,57,df,4c,97,cd,e2,c3,5a,61

41,87,dd,ef,24,ee,2c,30,ca,c9,6c,5b,eb,a1,e7

1e,7f,70,5e,ef,1c,89,70,14,82,42,6a,5d,88,36

b1,ce,b2,00,f4,1e,7f,aa,67,9a,a4,0f,43,c5,0f

2e,10,06,ed,22,56,f2,a8,21,91,ef,fe,34,04,14

58,99,a9,76,98,86,db,65,7e,b9,56,03,2b,26,ab
                                    8e,77

On Mon, May 24, 2010 at 3:08 PM, Dave Thompson <dthomp...@prinpay.com>wrote:

> >       From: owner-openssl-us...@openssl.org On Behalf Of Chuck Pareto
> >       Sent: Sunday, 23 May, 2010 22:06
>
> >       I'm a newbie when it comes to RSA, the last time I learned it was
> > in school over 7 years ago in one lecture.
> >       Maybe I'm missing something but I will try to explain my problem
> again.
> >       A former co worker generated a public and private key for our
> group.
>
> > (I think he used PGP but not sure).
> >       So I have the 2 .pem files he created. So far so good..
> >       Now, he's using openssl rsautl to encrypt and decrypt strings ...
> >       He's calling openssl rsautl from a c# script ...
> >       Now here is what I want to do. I want to use c#'s built in rsa
> class
>
> > to encrypt and decrypt these strings instead of [calling] openssl rsautl.
>
> Note: directly encrypting data (strings or other) with RSA is limited
> to somewhat less than the "key size" (more exactly, the modulus size).
> For a typical 1024-bit modulus this is about 100 bytes or maybe less.
> Most modern crypto schemes encrypt data which can be (almost) any size
> by a symmetric cipher (well-known ones are RC4, DES/3DES, and AES;
> there are more) using a random key, and encrypt that random data-key
> (which is inherently smallish, usually 8 or 16 bytes) using RSA.
> The recipient decrypts the data-key using RSA (and a longterm RSA key),
> and (then) the data using the symmetric cipher and the data-key.
> Unless your co-worker had a good reason for using RSA directly, this is
> often a sign of someone without appropriate knowledge "sprinkling on"
> security like magic dust, which has often led to insecure products.
> I can't know if that's true in your case, but it is a risk.
>
> >       On this link below there is an example of c# calling and ecrypting
> > with a public key, you don't have to go to this link..just for reference.
> >       http://msdn.microsoft.com/en-us/library/
> > system.security.cryptography.rsacryptoserviceprovider.encrypt.aspx
> (broken for mail)
> >       If I try to remove [setting .Exponent] it throws an error.
> > So I am guessing that a exponent needs to
> >       be defined in order to encrypt a message????Yes, no, I'm missing
> something..
>
> >       In your response to my first email, you said e and n are needed for
> encrypting.
> > If there is no e being passed in as an argument to openssl rsautl, what
> is
>
> > the default e? and what is the default n?
>
> e,n,d are common notation (shorthand) for the (Public)Exponent, Modulus,
> and PrivateExponent, so setting .Modulus and .Exponent of RSAKeyInfo
> which is then 'Import'ed to the Provider before that is used amounts
> to passing n and e. That example code confirms that the exponent is
> {1,0,1} *as a byte array*, thus 65537 or F4, as I guessed. Yes those
> two are needed and nothing else (except the data) for encrypt.
>
> For openssl rsautl (and other utilities) the public or private
> key as applicable is read from (or written to) a file, either
> a PEM file as you have or the (less robust) DER format. In your
> case, public.pem must be an RSA pubkey containing e and n, aka
> Exponent and Modulus, as you can see with the command I gave:
>   openssl rsa -in public.pem -pubin -noout -text
> Your second .pem should be privkey; guessing it's private.pem:
>  openssl rsa -in private.pem -noout -text # note no -pubin
> will similarly show you the additional fields in a privkey
> (p,q=prime1,2; dP,dQ=exponent1,2; qInv=coefficient). Since
> the RSA pubkey is a subset of the (usual=PKCS1) privkey,
> rsautl -encrypt can use either; but in any sensible use,
> you would give only the pubkey, not the privkey, to the
> people/systems that (you want to) do encryption.
>
> When an RSA keypair is *generated*, there can be a default for
> e, since it is not secret and should be small for efficiency.
> F4 as in the code example is popular, and is openssl's default.
> Maybe openpgp too, if your 'think' is correct; I don't know.
> But once a key exists you should use the e in the key and not
> assume or require it to be any particular or default value.
>
> Aside: that Encrypt example shows encrypting the key and IV from a
> RijndaelManaged object. Rijndael is for practical purposes AES, so
> this would be consistent with the usual scheme as I described above
> (encrypt data with AES=Rijndael, and encrypt data-key with RSA),
> although I have no idea what the 'Managed' adds to the picture.
> On the other hand, encrypting the IV is not needed and rarely if
> ever done. The example isn't complete and doesn't show using the
> results, so it could be they mean to encrypt IV just as an example
> of multiple operations and then discard that result. It would be
> better if they had some comments or explanation though.
>
>
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org
>

Reply via email to