[openssl.org #3229]
Yes, I suspected the same. But even though it returns 129, I prepended "00"
to the hex string and sent it as argument to to RSA_verify.

authMsgLen = RSA_size(rsa_pb);
authMsgHexStr = "00" + authMsgHexStr;

RSA_verify(NID_md5, digest, MD5_DIGEST_LENGTH,
       (unsigned char *)authMsgHexStr.c_str(), authMsgLen, rsa_pb)

Here authMsgLen = 129 and authMsgHexStr has been prepended with "00"
But still verification fails.

Thanks,
Som



On Sat, Jan 11, 2014 at 10:46 PM, da...@familyboyce.co.uk via RT <
r...@openssl.org> wrote:

> I suspect there may be a discrepancy of the meaning of RSA_Size() on the
> two implementations, possibly arising from ASN.1 encoding considerations.
>
> When your number is converted into hex representation, it has 128 bytes:
>
> DD626D4C5DA0D9296ED31044F9568D7E6EB37F30D548225041D158DB
> 012B6ED13394E2F993ED4F481DC49D8458C5BB2C1A443430594E3C0B
> CF59AE904D2D7C7C20150A6A6DB6686BF5CF8173C5AD2A2C2E317BB
> 339659CD1D6C04170854B5262FB39F16AF25FEA972B624C480E153E55
> AB2D31D62296ECE8A4A1D674410AA2A9
>
> However, as a 128-bit ASN.1 integer, this is a negative value (leftmost
> bit is
> set), and all RSA integers must be represented as positive values; for this
> reason, the ASN.1 value must include a leading 00 byte, making it a 129
> byte representation of a 128-byte positive value.
>
> The online documentation for RSA_Size() suggest that the size is for an
> 'RSA encrypted value', which for this key would be 128 bytes - although if
> that velue were then to be ASN.1 encoded, it may require an additional
> byte.
>
> I realise this comment doesn't really solve your problem, but I'm hoping
> that
> it will help someone to decide the canonical interpretation of RSA_size()
> so
> that the broken implementation can be determined and fixed.
>
> David Boyce
>
> On 11 Jan 2014 at 12:09, Som M via RT wrote:
>
> > Hi,
> > We are facing some issue with rsa key size while porting our application
> > from montavista to RHEL 6.4.
> >
> > The RSA key size(RSA_size) for montavista is returning 128 bytes but on
> > RHEL its returning 129 bytes.
> >
> > #include <openssl/bn.h>
> >
> > #include <stdlib.h>
> > #include <time.h>
> > #include <openssl/ssl.h>
> > #include <openssl/rsa.h>
> > #include <openssl/md5.h>
> > #include <openssl/evp.h>
> >
> >
> > /*using namespace std; */
> > int main()
> > {
> >
> > RSA *rsa_pb = 0;
> > unsigned int authMsgLen = 0;
> > rsa_pb = RSA_new();
> > static char evc41_lg_n[] =
> >
> "155461468878137924780952081903031227576222509385846279319048916001752025100615237943340425486157346876604219223131643357452911097864741470169369275270067558869064161833650298945491423162034462611882047283976121790220680041467155931440845770244995083344133190925465159949456383958641405933050126040553008833193";*
> > // evc41 lg public exponent
> > static char evc41_lg_e[] = "65537";
> >
> > BN_dec2bn( &(rsa_pb->n), evc40_lg_n);
> > BN_dec2bn( &(rsa_pb->e), evc40_lg_e);
> >
> > authMsgLen = RSA_size(rsa_pb);
> > printf("Msg Length:z %d:%d",authMsgLen,z);
> >
> > return 0;
> > }
> >
> > authMsgLen in montavista is 128 and for rhel 6.4 it is 129.
> >
> > There is a check in our code which checks authMsgLen against 128 and this
> > fails in rhel. We commented the same but later RSA_verify also failed.
> >
> > Montavista openssl version : 0.98
> > RHEL openssl version : 1.0.0
> >
> > Can anyone please let me know what is the issue?
> >
> > Thanks,
> > Som
> >
> > ______________________________________________________________________
> > OpenSSL Project                                 http://www.openssl.org
> > Development Mailing List                       openssl-...@openssl.org
> > Automated List Manager                           majord...@openssl.org
>
> --
> da...@familyboyce.co.uk
>
>
>

Reply via email to