a thoughtful web.
Share good ideas and conversation.   Login or Take a Tour!
lcguedes's profile
lcguedes


stats
following: 1
followed tags: 0
followed domains: 0
badges given: 0 of 0
hubskier for: 2475 days

recent comments, posts, and shares:
lcguedes  ·  2467 days ago  ·  link  ·    ·  parent  ·  post: A simple hexadecimal "bignum" library, in C.

Sorry about the expmod function. As you said, I have just renamed it.

This decrypt function works only for data encrypted with the private key (d,n). Thus, it is useful for checking signatures not for decrypting actual data.

if you try the code below you will see it will fail:

   HB_hex_string_to_hex_bignum( TEST_PUBLIC_KEY_EXP, &(publicKey.e) );

   HB_hex_string_to_hex_bignum( TEST_PUBLIC_KEY_MOD, &(publicKey.n) );

   HB_int_to_hex_bignum( 0, &privateKey.e );
   HB_int_to_hex_bignum( 0, &privateKey.n );

   HB_hex_string_to_hex_bignum( TEST_RESULT, &rsaOrig );

   rsaEncrypt( &rsaOrig, &rsaEncrypted, &publicKey );

   rsaDecrypt( &rsaEncrypted, &rsaDecrypted, &publicKey );

   if ( HB_compare( &rsaOrig, &rsaDecrypted ) == 0 )
   {
      printf( "Passed!\n" );
   }
   else
   {
      printf( "Failed!\n" );
   }
lcguedes  ·  2468 days ago  ·  link  ·    ·  parent  ·  post: A simple hexadecimal "bignum" library, in C.

Thank you for your decrypt, but I think it is not going to work. You need something like:

  ////////////////////////////////////////////////////////////////////////////
  //
  void rsaDecrypt( hex_bignum_t *ciphertext_ptr, hex_bignum_t *plaintext_ptr, rsaSecKey_t *privkey_ptr )
  {
     HB_modexp( ciphertext_ptr, &(privkey_ptr->d), &(privkey_ptr->n), plaintext_ptr );
  }
where, (d * e) % ((p-1)*(q-1)) = 1, p*q = n.
lcguedes  ·  2474 days ago  ·  link  ·    ·  parent  ·  post: A simple hexadecimal "bignum" library, in C.

Thank you! I will try now to write the decrypt function...:-)

lcguedes  ·  2475 days ago  ·  link  ·    ·  parent  ·  post: A simple hexadecimal "bignum" library, in C.

could you also share your (presumably light) rsa code?:-)