diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2005-02-10 20:11:35 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2005-02-10 20:11:35 +0000 |
commit | f43c373b4268c07195447036d0d92cb2c9e3781a (patch) | |
tree | d6826ed86399620f32644853b53ee997680f1fa0 /emsa2.cpp | |
parent | 242d67fb17619670d9b757c442dcf2e26d8478a1 (diff) | |
download | cryptopp-f43c373b4268c07195447036d0d92cb2c9e3781a.tar.gz |
add missing files
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@196 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'emsa2.cpp')
-rwxr-xr-x | emsa2.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/emsa2.cpp b/emsa2.cpp new file mode 100755 index 0000000..ef8672e --- /dev/null +++ b/emsa2.cpp @@ -0,0 +1,34 @@ +// emsa2.cpp - written and placed in the public domain by Wei Dai + +#include "pch.h" +#include "emsa2.h" + +#ifndef CRYPTOPP_IMPORTS + +NAMESPACE_BEGIN(CryptoPP) + +void EMSA2Pad::ComputeMessageRepresentative(RandomNumberGenerator &rng, + const byte *recoverableMessage, unsigned int recoverableMessageLength, + HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, + byte *representative, unsigned int representativeBitLength) const +{ + assert(representativeBitLength >= MinRepresentativeBitLength(hashIdentifier.second, hash.DigestSize())); + + if (representativeBitLength % 8 != 7) + throw PK_SignatureScheme::InvalidKeyLength("EMSA2: EMSA2 requires a key length that is a multiple of 8"); + + unsigned int digestSize = hash.DigestSize(); + unsigned int representativeByteLength = BitsToBytes(representativeBitLength); + + representative[0] = messageEmpty ? 0x4b : 0x6b; + memset(representative+1, 0xbb, representativeByteLength-digestSize-4); // pad with 0xbb + byte *afterP2 = representative+representativeByteLength-digestSize-3; + afterP2[0] = 0xba; + hash.Final(afterP2+1); + representative[representativeByteLength-2] = *hashIdentifier.first; + representative[representativeByteLength-1] = 0xcc; +} + +NAMESPACE_END + +#endif |