[Fwd: [xmlsec] Loading PEM keys from memory instead of a file]

Meg Morgan meg@votehere.net
Fri, 24 Jan 2003 22:04:52 +0000


This is a multi-part message in MIME format.
--------------496B9729C9E550C76A586FF9
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Oops forgot to send it to the list too..


--------------496B9729C9E550C76A586FF9
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

X-Mozilla-Status2: 00000000
Message-ID: <3E31B811.B96F1715@votehere.net>
Date: Fri, 24 Jan 2003 22:02:57 +0000
From: Meg Morgan <meg@votehere.net>
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Aleksey Sanin <aleksey@aleksey.com>
Subject: Re: [xmlsec] Loading PEM keys from memory instead of a file
References: <3E317D3F.30C40386@votehere.net> <3E318704.6030503@aleksey.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Hmm, xmlSecDsaKeyGenerate is returning -1 for me.
The console says:

<..\src\dsa.c:533>: error 100: assertion : key != NULL

Here's the input:

xmlSecKeyPtr key = NULL;
DSA * dsa = NULL;
char *passwd = "";
std::string prvkey_str;
int retval = 0;

prvkey_str is
-----BEGIN DSA PRIVATE KEY-----
MIIBuwIBAAKBgQDg+63XjxDXIo7Lw85D763NdoqzKABrls7WWd0sdQ3hEPHPZvKr
dic+/KJJJqsYzM0+ig6jTUf8ugP4eThVd9tT15rQXStXxjvytBm+9eVRW0Ssbp2d
uT6xinmqg37DkJS5W7O4NhEtGUHwhyVh9+eK6+khLd/A6+9fVdbIiJ0z4wIVALPo
7NzxKJtkSg+s23mMBrelZxwrAoGBAIXa7nkBtIYQ5RSLAiqpOzdxEAo+BwL+OSpF
yWiyiYBqhkKu0KRDqpgFT6eJv02mgVZUhtaJb9F6TdKkF3mUCRq9oXqrBHBO++KW
2O6bitIzQNrYzrsQnhZxufB9xcvOBH7DXBUtViA2S/BEj1jOFMCkEBmj9sb6JJLM
fu0TnMXLAoGAKZJPD+ylOtVxH0feMbOqxU+0hoSay3Ay0d+W209g6dr+rx4zCLHl
ah5Y+bSwKrS6VxPx1DFzseR02EUPLbKKcs/mPffVzDk9XmDD+sFvAkH2RMOvkKKu
+cTsL+TlyIK8bpd4fukKBLmJabONhkLzle18gjgSXmF9dF9/QgVLrE4CFBQ1MEFd
OsxrvlDFm8K05YVYQxhY
-----END DSA PRIVATE KEY-----

Code:

BIO * mem = BIO_new_mem_buf(
            const_cast<void *>(static_cast<const void *>(prvkey_str.data())), prvkey_str.size());
dsa=PEM_read_bio_DSAPrivateKey(mem, NULL, NULL, passwd);      
retval = xmlSecDsaKeyGenerate(key, dsa);

Any ideas?

Thanks,
meg

Aleksey Sanin wrote:
> 
> http://www.aleksey.com/xmlsec/api/xmlsec-transforms.html#XMLSECRSAKEYGENERATE
> http://www.aleksey.com/xmlsec/api/xmlsec-transforms.html#XMLSECDSAKEYGENERATE
> ....
> 
> Yes, I know that the function names are bad :(
> 
> Aleksey
> 
> Meg Morgan wrote:
> 
> >Currently I'm generating RSA and DSA keys with openssl
> >and saving them into files, then using xmlSecSimpleKeysMngrLoadPemKey
> >to load them into the key manager.  What I really want to do is to
> >load the keys as char*s or strings from memory.  I'd rather not assume
> >a file system at all.  How do I load keys from memory?
> >
> >Thanks,
> >meg morgan
> >
> >
> >

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Meg Morgan                           425/450-2754
meg@votehere.net                   http://www.votehere.net

--------------496B9729C9E550C76A586FF9--