Hi All,
I am trying to encrypt message using cryptopp RSA-OAEP encryption
scheme. Is there any way that I can pass my own seed value, plain-text
and get the cipher-text ? I want to do this because, I want to check
whether I am using the right encryption scheme for my project. I have
the expected cipher-text and hash value for a given plain-text, seed
values.
please see below for my code, which works when I pass
autoseededrandompool object to encrypt function.
Thanks a lot.
Kind Regards,
dragon
CODE:
AutoSeededRandomPool rng;
/// Load Public key from hex input
RSA::PublicKey pubkey_rx;
const byte pub_rx_modulus[128] = { 0xbc, 0x83, 0xc7, 0x95, 0x78,
0xf9,
0x0c, 0x91, 0x4b, 0x89, 0x38, 0x05, 0x5a, 0xa4,
0xac, 0x1f,
0xa8, 0x03, 0x93, 0x82, 0x79, 0x75, 0xaf, 0x66,
0x22, 0xde,
0x43, 0x80, 0x8d, 0xcd, 0x5d, 0x90, 0xb8, 0x3c,
0xb3, 0xd8,
0x9e, 0xb0, 0x0d, 0x09, 0x44, 0xf4, 0x3f, 0x5f,
0xab, 0xb9,
0xc4, 0xc9, 0x96, 0xef, 0x78, 0xb5, 0x8f, 0x69,
0x77, 0xb4,
0x7d, 0x08, 0x14, 0x9c, 0x81, 0xa0, 0x8f, 0x04,
0x1f, 0xa0,
0x88, 0xe1, 0x20, 0xc7, 0x34, 0x4a, 0x49, 0x35,
0x65, 0x99,
0xcf, 0x53, 0x19, 0xf0, 0xc6, 0x81, 0x76, 0x05,
0x5c, 0xb9,
0xde, 0xdd, 0xab, 0x3d, 0xb0, 0x92, 0xa1, 0x23,
0x4f, 0x0c,
0x71, 0x30, 0x42, 0x78, 0xf6, 0x55, 0xae, 0xbd,
0x36, 0x25,
0x8e, 0x25, 0x0d, 0x4e, 0x5e, 0x8e, 0x77, 0x6a,
0x60, 0xe3,
0xc1, 0xe9, 0xee, 0xcd, 0x2b, 0x9e, 0x18, 0x63,
0x97, 0xd4,
0xe6, 0x75 };
const byte pub_rx_exp[3] = { 0x01, 0x00, 0x01 };
const Integer pb_modulus(pub_rx_modulus, 128,
Integer::UNSIGNED);
const Integer pb_exp(pub_rx_exp, 3, Integer::UNSIGNED);
pubkey_rx.Initialize(pb_modulus, pb_exp);
const byte plain_txt[16] = { 0x68, 0xbc, 0xc5, 0x1b, 0xa9, 0xdb,
0x1b,
0xd0, 0xfa, 0xf1, 0x5e, 0x9a, 0xd8, 0xa5, 0xaf,
0xb9 };
SecByteBlock plaintext((unsigned char *) &plain_txt, 16);
////////////////////////////////////////////////
// Encrypt
RSAES<OAEP<SHA256> >::Encryptor encryptor(pubkey_rx);
// Now that there is a concrete object, we can validate
static const int SECRET_SIZE = 16;
assert( 0 != encryptor.FixedMaxPlaintextLength() );
assert( SECRET_SIZE <= encryptor.FixedMaxPlaintextLength() );
// Create cipher text space
size_t ecl = encryptor.CiphertextLength(plaintext.size());
assert( 0 != ecl );
SecByteBlock ciphertext(ecl);
const byte seed[32] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
0x06,
0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11,
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
0x1A, 0x1B,
0x1C, 0x1D, 0x1E, 0x1F };
// Paydirt
encryptor.Encrypt(rng, plaintext, plaintext.size(), ciphertext);
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
To unsubscribe from this group, send email to
cryptopp-users+unsubscribegooglegroups.com or reply to this email with the
words "REMOVE ME" as the subject.