8#include <botan/emsa1.h>
17 if(8*msg.size() <= output_bits)
20 size_t shift = 8*msg.
size() - output_bits;
22 size_t byte_shift = shift / 8, bit_shift = shift % 8;
25 for(
size_t j = 0; j != msg.size() - byte_shift; ++j)
31 for(
size_t j = 0; j != digest.size(); ++j)
33 byte temp = digest[j];
34 digest[j] = (temp >> bit_shift) | carry;
35 carry = (temp << (8 - bit_shift));
46void EMSA1::update(
const byte input[],
size_t length)
48 hash->update(input, length);
66 if(msg.size() != hash->output_length())
67 throw Encoding_Error(
"EMSA1::encoding_of: Invalid size for input");
68 return emsa1_encoding(msg, output_bits);
78 if(raw.size() != hash->output_length())
79 throw Encoding_Error(
"EMSA1::encoding_of: Invalid size for input");
81 SecureVector<byte> our_coding = emsa1_encoding(raw, key_bits);
83 if(our_coding == coded)
return true;
84 if(our_coding[0] != 0)
return false;
85 if(our_coding.size() <= coded.size())
return false;
88 while(our_coding[offset] == 0 && offset < our_coding.size())
90 if(our_coding.size() - offset != coded.size())
93 for(
size_t j = 0; j != coded.size(); ++j)
94 if(coded[j] != our_coding[j+offset])
virtual SecureVector< byte > raw_data()=0
std::invalid_argument Invalid_Argument
Encoding_Error(const std::string &name)