1
/*************************************************
2
* PKCS1 EME Source File *
3
* (C) 1999-2007 The Botan Project *
4
*************************************************/
11
/*************************************************
12
* PKCS1 Pad Operation *
13
*************************************************/
14
SecureVector<byte> EME_PKCS1v15::pad(const byte in[], u32bit inlen,
20
throw Encoding_Error("PKCS1: Output space too small");
22
throw Encoding_Error("PKCS1: Input is too large");
24
SecureVector<byte> out(olen);
27
for(u32bit j = 1; j != olen - inlen - 1; ++j)
29
out[j] = Global_RNG::random();
30
out.copy(olen - inlen, in, inlen);
35
/*************************************************
36
* PKCS1 Unpad Operation *
37
*************************************************/
38
SecureVector<byte> EME_PKCS1v15::unpad(const byte in[], u32bit inlen,
41
if(inlen != key_len / 8 || inlen < 10 || in[0] != 0x02)
42
throw Decoding_Error("PKCS1::unpad");
45
for(u32bit j = 0; j != inlen; ++j)
52
throw Decoding_Error("PKCS1::unpad");
54
return SecureVector<byte>(in + seperator + 1, inlen - seperator - 1);
57
/*************************************************
58
* Return the max input size for a given key size *
59
*************************************************/
60
u32bit EME_PKCS1v15::maximum_input_size(u32bit keybits) const
63
return ((keybits / 8) - 10);