Hi,
 
    I've implemented (in C++) a simple form of shamir secret sharing for the particular case (3,5). One function receives a BIGNUM A0 an generates the 5 secrets. Another function, receives 3 secrets and generates the recover BIGNUM A0. It's working fine.
 
    The problem is that I need to convert a RSA private key into a BIGNUM A0, and I'm having trouble with this.
 
     I was trying to do this (part of my code):
 
        RSA *Ch_Ap
        unsigned char *buffer, *next;
        BIGNUM *sec_BN = BN_new();
        Ch_Ap = RSA_generate_key(2048, RSA_F4, NULL, 0);
        int size = i2d_RSAPrivateKey(Ch_Ap, 0);
        buffer = next =(unsigned char *)malloc(size);
        i2d_RSAPrivateKey(Ch_Ap, &next);
        BN_bin2bn(buffer, size, sec_BN); 
 
     However, when I use sec_BN in my functions, the recovered BIGNUM is not the same as sec_BN. When I pass another BIGNUM, for example using the function BN_rand_range(), then the recovered BIGNUM is equal (proving that my secret sharing functions is ok).
 
      I think it can be something about Big-Endian conversion in sec_BN, but I didn't find a way to do this conversion and I don't know if it is necessary too.
 
 
       Thanks in advance,
 
 
                Rafael Cividanes.
 
 


O Yahoo! está de cara nova. Venha conferir!

Reply via email to