I'm attempting to write a wrapper aroung the API defined for the
trusted platform module. The Design Principles specification from the
trusted computing group (http://www.trustedcomputinggroup.org/
resources/tpm_main_specification) states that when using the
TPM_ES_RSAESOAEP_SHA1_MGF1 encryption type, that " The OAEP encoding P
parameter MUST be the 4 character string “TCPA”  ".

I use the following code when performing RSAES_OAEP encryption. How
can I modify it to set the padding parameter to "TCPA"?

std::vector<BYTE> EncryptDataUsingRSAES_OAEP_SHA(       std::vector<BYTE>
vDataToEncrypt,
                                                std::vector<BYTE> 
vTpmRsaPubKeyModulus)
{

        std::vector<BYTE> cipher;

        CryptoPP::AutoSeededRandomPool rng;
        CryptoPP::Integer modulus(&vTpmRsaPubKeyModulus[0],
vTpmRsaPubKeyModulus.size());
        CryptoPP::RSA::PublicKey publicKey;

        publicKey.SetPublicExponent(65537); // TPM uses 65537 as public
exponent
        publicKey.SetModulus(modulus);

        CryptoPP::RSAES_OAEP_SHA_Encryptor e(publicKey);

        CryptoPP::SecByteBlock
sbbCipherText(e.CiphertextLength(vDataToEncrypt.size()));

        e.Encrypt( rng, &vDataToEncrypt[0], vDataToEncrypt.size(),
sbbCipherText.begin() );

        cipher.assign(sbbCipherText.BytePtr(), sbbCipherText.BytePtr() +
sbbCipherText.size());

        return cipher;

}

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com.
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to