On 10/19/07, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I am currently trying to convert from OpenSSL to NSS (seemed like a good
> idea at the time).   The code that I currently have an issue with is
> essentially ...
>
>   key=RSA_new();
>   if (key) {
>     key->n=BN_bin2bn(IssPubKey,IssPubKeyLgth,NULL);
>     key->e=BN_bin2bn(PubKeyExponent->value,PubKeyExponent->lgth,NULL);
>     decrypt_lgth=RSA_public_decrypt(lgth, value, (unsigned char
> *)recovered, key, RSA_NO_PADDING);
>   }
>   RSA_free(key);
>
>
> but the key is a public key.
>
>
> I originally though that function PK11_PubDecryptRaw would provide the
> same outcome (having encoded and imported the key - see NSS tech note #7)
> but now realise that it only uses a private key (the normal way of doing
> things) and cannot be used with a public key.  I cannot find any other
> function that will do this - so, is there a function that I haven't
> spotted yet or am I completely wrong with this approach? !

Alan,

Try PK11_PubEncryptRaw, PK11_PubEncryptPKCS1, PK11_VerifyRecover,
and PK11_Verify.  Use our LXR source code browser to look at these
functions, for example:
http://lxr.mozilla.org/security/ident?i=PK11_PubEncryptRaw

Because of the RSA_NO_PADDING flag in the OpenSSL code, I
think PK11_PubEncryptRaw is the function you need.  This function's
name is very confusing for what you'll use it for.  You can consider
as if the function were named PK11_VerifyRecoverRaw.

Wan-Teh
_______________________________________________
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to