~ubuntu-branches/debian/squeeze/pycryptopp/squeeze

« back to all changes in this revision

Viewing changes to cryptopp/emsa2.h

  • Committer: Bazaar Package Importer
  • Author(s): Zooko O'Whielacronx
  • Date: 2009-06-22 22:20:50 UTC
  • Revision ID: james.westby@ubuntu.com-20090622222050-hbqmn50dt2kvoz5o
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef CRYPTOPP_EMSA2_H
 
2
#define CRYPTOPP_EMSA2_H
 
3
 
 
4
/** \file
 
5
        This file contains various padding schemes for public key algorithms.
 
6
*/
 
7
 
 
8
#include "cryptlib.h"
 
9
#include "pubkey.h"
 
10
 
 
11
#ifdef CRYPTOPP_IS_DLL
 
12
#include "sha.h"
 
13
#endif
 
14
 
 
15
NAMESPACE_BEGIN(CryptoPP)
 
16
 
 
17
template <class H> class EMSA2HashId
 
18
{
 
19
public:
 
20
        static const byte id;
 
21
};
 
22
 
 
23
template <class BASE>
 
24
class EMSA2HashIdLookup : public BASE
 
25
{
 
26
public:
 
27
        struct HashIdentifierLookup
 
28
        {
 
29
                template <class H> struct HashIdentifierLookup2
 
30
                {
 
31
                        static HashIdentifier Lookup()
 
32
                        {
 
33
                                return HashIdentifier(&EMSA2HashId<H>::id, 1);
 
34
                        }
 
35
                };
 
36
        };
 
37
};
 
38
 
 
39
// EMSA2HashId can be instantiated with the following classes.
 
40
class SHA1;
 
41
class RIPEMD160;
 
42
class RIPEMD128;
 
43
class SHA256;
 
44
class SHA384;
 
45
class SHA512;
 
46
class Whirlpool;
 
47
class SHA224;
 
48
// end of list
 
49
 
 
50
#ifdef CRYPTOPP_IS_DLL
 
51
CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA1>;
 
52
CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA224>;
 
53
CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA256>;
 
54
CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA384>;
 
55
CRYPTOPP_DLL_TEMPLATE_CLASS EMSA2HashId<SHA512>;
 
56
#endif
 
57
 
 
58
//! _
 
59
class CRYPTOPP_DLL EMSA2Pad : public EMSA2HashIdLookup<PK_DeterministicSignatureMessageEncodingMethod>
 
60
{
 
61
public:
 
62
        static const char * CRYPTOPP_API StaticAlgorithmName() {return "EMSA2";}
 
63
        
 
64
        size_t MinRepresentativeBitLength(size_t hashIdentifierLength, size_t digestLength) const
 
65
                {return 8*digestLength + 31;}
 
66
 
 
67
        void ComputeMessageRepresentative(RandomNumberGenerator &rng, 
 
68
                const byte *recoverableMessage, size_t recoverableMessageLength,
 
69
                HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty,
 
70
                byte *representative, size_t representativeBitLength) const;
 
71
};
 
72
 
 
73
//! EMSA2, for use with RWSS and RSA_ISO
 
74
/*! Only the following hash functions are supported by this signature standard:
 
75
        \dontinclude emsa2.h
 
76
        \skip EMSA2HashId can be instantiated
 
77
        \until end of list
 
78
*/
 
79
struct P1363_EMSA2 : public SignatureStandard
 
80
{
 
81
        typedef EMSA2Pad SignatureMessageEncodingMethod;
 
82
};
 
83
 
 
84
NAMESPACE_END
 
85
 
 
86
#endif