Mixe for Privacy and Anonymity in the Internet
CAASymCipher.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2000, The JAP-Team
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6 
7  - Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright
11 notice,
12  this list of conditions and the following disclaimer in the
13 documentation and/or
14  other materials provided with the distribution.
15 
16  - Neither the name of the University of Technology Dresden, Germany nor
17 the names of its contributors
18  may be used to endorse or promote products derived from this software
19 without specific
20  prior written permission.
21 
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
24 AND ANY EXPRESS
25 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 MERCHANTABILITY
27 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 REGENTS OR CONTRIBUTORS
29 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 CONSEQUENTIAL DAMAGES
31 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA,
33 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 LIABILITY, WHETHER
35 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 ARISING IN ANY WAY
37 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
38 DAMAGE
39 */
40 #ifndef __CAASYMCIPHER__
41 #define __CAASYMCIPHER__
42 #include "CACertificate.hpp"
43 
44 #define RSA_SIZE 128
45 
46 
48 {
49  public:
50  CAASymCipher();
51  ~CAASymCipher();
52  SINT32 destroy();
53  SINT32 decrypt(const UINT8 *from, UINT8 *to);
54  SINT32 decryptOAEP(const UINT8 *from, UINT8 *to, UINT32 *len);
55  SINT32 encrypt(const UINT8 *from, UINT8 *to);
56  SINT32 encryptOAEP(const UINT8 *from, UINT32 fromlen, UINT8 *to, UINT32 *len);
57  SINT32 encryptPKCS1(const UINT8 *from, UINT32 fromlen, UINT8 *to,
58  UINT32 *len);
60 // SINT32 getPublicKey(UINT8* buff,UINT32 *len);
61 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
62 
63  SINT32 getPublicKeyAsDOMElement(DOMElement *&elemRoot, XERCES_CPP_NAMESPACE::DOMDocument *docOwner);
64 #endif
65 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
66  private:
67  SINT32 addKeyPart(DOMElement *elemRoot, XERCES_CPP_NAMESPACE::DOMDocument *docOwner,
68  const char *partName, BIGNUM *part);
69 #endif
70 #ifndef ONLY_LOCAL_PROXY
71 
72  public:
74 #ifdef EXPORT_ASYM_PRIVATE_KEY
75  SINT32 getPrivateKeyAsXML(UINT8 *buff, UINT32 *len);
76  SINT32 getPrivateKeyAsDOMElement(DOMElement *&elemRoot,
77  XERCES_CPP_NAMESPACE::DOMDocument *docOwner);
78  SINT32 setPrivateKeyAsXML(const UINT8 *buff, UINT32 len);
79  SINT32 setPrivateKeyAsDOMNode(DOMNode *node);
80 #endif
81  // SINT32 getPublicKeySize();
82  // SINT32 setPublicKey(UINT8* buff,UINT32* len);
83  SINT32 setPublicKey(const CACertificate *pCert);
84  SINT32 setPublicKeyAsXML(const UINT8 *buff, UINT32 len);
85 #endif
86  private:
87  SINT32 getKeyPart(BIGNUM **part, DOMNode *node);
88 
89  public:
90  SINT32 setPublicKeyAsDOMNode(DOMNode *node);
91 
92  // Set the public key from a Base64 encodes exponent and modulus
93  SINT32 setPublicKey(const UINT8 *modulus, UINT32 moduluslen,
94  const UINT8 *exponent, UINT32 exponentlen);
95 
96  static SINT32 testSpeed();
97 
98  private:
99  RSA *m_pRSA;
100 };
101 
102 void setRSAFlags(RSA *pRSA);
103 
104 
105 #endif
void setRSAFlags(RSA *pRSA)
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
static SINT32 testSpeed()
SINT32 getPublicKeyAsXML(UINT8 *buff, UINT32 *len)
Stores the public key in buff.
SINT32 addKeyPart(DOMElement *elemRoot, XERCES_CPP_NAMESPACE::DOMDocument *docOwner, const char *partName, BIGNUM *part)
SINT32 encryptPKCS1(const UINT8 *from, UINT32 fromlen, UINT8 *to, UINT32 *len)
Encrypts one block of plain text using PKCS1 padding.
SINT32 getPublicKeyAsDOMElement(DOMElement *&elemRoot, XERCES_CPP_NAMESPACE::DOMDocument *docOwner)
SINT32 setPublicKeyAsDOMNode(DOMNode *node)
SINT32 setPublicKeyAsXML(const UINT8 *buff, UINT32 len)
Sets the public key to the values stored in key.
SINT32 generateKeyPair(UINT32 size)
Generates a new random key-pair of size bits.
SINT32 decryptOAEP(const UINT8 *from, UINT8 *to, UINT32 *len)
Decrypts one OAEP encoded block which is stored in from.
SINT32 encryptOAEP(const UINT8 *from, UINT32 fromlen, UINT8 *to, UINT32 *len)
Encrypts one block of plain text using OAEP padding.
SINT32 decrypt(const UINT8 *from, UINT8 *to)
Decrypts exactly one block which is stored in from.
SINT32 destroy()
SINT32 encrypt(const UINT8 *from, UINT8 *to)
Encrypts exactly one block which is stored in from.
SINT32 setPublicKey(const CACertificate *pCert)
Sets the public key which is used for encryption to the contained in the provided certificate.
SINT32 getKeyPart(BIGNUM **part, DOMNode *node)
UINT16 len
Definition: typedefs.hpp:0