diff options
| author | Malf Furious <m@lfurio.us> | 2016-04-13 21:05:14 -0400 | 
|---|---|---|
| committer | Malf Furious <m@lfurio.us> | 2016-04-13 21:05:14 -0400 | 
| commit | 490d36e65ac24e34e3021c2a0947384aee138c88 (patch) | |
| tree | 418a229fa60708d7796bc61f90794626aefed9d5 /cryptopp562/emsa2.cpp | |
| download | compass-490d36e65ac24e34e3021c2a0947384aee138c88.tar.gz compass-490d36e65ac24e34e3021c2a0947384aee138c88.zip | |
Root commit for new Compass repository
This is the Alpha version of ComPASS, originally developed sometime in
2014.
Diffstat (limited to 'cryptopp562/emsa2.cpp')
| -rw-r--r-- | cryptopp562/emsa2.cpp | 34 | 
1 files changed, 34 insertions, 0 deletions
| diff --git a/cryptopp562/emsa2.cpp b/cryptopp562/emsa2.cpp new file mode 100644 index 0000000..3dbb7e8 --- /dev/null +++ b/cryptopp562/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, size_t recoverableMessageLength, +	HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, +	byte *representative, size_t 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"); + +	size_t digestSize = hash.DigestSize(); +	size_t 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 | 
