00001
#ifndef CRYPTOPP_OAEP_H
00002
#define CRYPTOPP_OAEP_H
00003
00004
#include "pubkey.h"
00005
#include "sha.h"
00006
00007 NAMESPACE_BEGIN(CryptoPP)
00008
00009
00010 class CRYPTOPP_DLL
OAEP_Base : public
PK_EncryptionMessageEncodingMethod
00011 {
00012
public:
00013
bool ParameterSupported(
const char *name)
const {
return strcmp(name, Name::EncodingParameters()) == 0;}
00014
unsigned int MaxUnpaddedLength(
unsigned int paddedLength)
const;
00015
void Pad(
RandomNumberGenerator &rng,
const byte *raw,
unsigned int inputLength, byte *padded,
unsigned int paddedLength,
const NameValuePairs ¶meters)
const;
00016
DecodingResult Unpad(
const byte *padded,
unsigned int paddedLength, byte *raw,
const NameValuePairs ¶meters)
const;
00017
00018
protected:
00019
virtual unsigned int DigestSize()
const =0;
00020
virtual HashTransformation * NewHash()
const =0;
00021
virtual MaskGeneratingFunction * NewMGF()
const =0;
00022 };
00023
00024
00025
template <
class H,
class MGF=P1363_MGF1>
00026 class OAEP :
public OAEP_Base,
public EncryptionStandard
00027 {
00028
public:
00029
static std::string StaticAlgorithmName() {
return std::string(
"OAEP-") + MGF::StaticAlgorithmName() +
"(" + H::StaticAlgorithmName() +
")";}
00030
typedef OAEP<H, MGF> EncryptionMessageEncodingMethod;
00031
00032
protected:
00033
unsigned int DigestSize()
const {
return H::DIGESTSIZE;}
00034
HashTransformation * NewHash()
const {
return new H;}
00035
MaskGeneratingFunction * NewMGF()
const {
return new MGF;}
00036 };
00037
00038 CRYPTOPP_DLL_TEMPLATE_CLASS
OAEP<SHA>;
00039
00040 NAMESPACE_END
00041
00042
#endif