sipxportlib  Version 3.3
UtlCryptoKeySym.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2008 SIPez LLC.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // Copyright (C) 2008 Mutualink, Inc.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 // Author: Sergey Kostanbaev <Sergey DOT Kostanbaev AT sipez DOT com>
15 
16 #ifndef _UtlCryptoKeySym_h_
17 #define _UtlCryptoKeySym_h_
18 
19 // SYSTEM INCLUDES
20 // APPLICATION INCLUDES
21 #include "utl/UtlCryptoKey.h"
22 
23 // DEFINES
24 // MACROS
25 // EXTERNAL FUNCTIONS
26 // EXTERNAL VARIABLES
27 // STRUCTS
28 // TYPEDEFS
29 // FORWARD DECLARATIONS
30 
35 {
36 /* //////////////////////////////// PUBLIC //////////////////////////////// */
37 public:
38 
39 /* =============================== CREATORS =============================== */
41 
42 
45 
48 
50 
51 /* ============================= MANIPULATORS ============================= */
53 
54 
56  int generateKey();
62  int loadBinaryKey(const unsigned char* pSrc, int srcLen);
68  UtlCryptoData* getBinaryKey() const;
70 
72  int getMaxEncryptedSize(int srcLen) const;
73 
75  int encrypt(const unsigned char* pSrc,
76  int srcLen,
77  unsigned char* pDest,
78  int* pDestLen) const;
79 
80  int getMaxDecryptedSize(int srcLen) const;
81 
83  int decrypt(const unsigned char* pSrc,
84  int srcLen,
85  unsigned char* pDest,
86  int* pDestLen) const;
87 
89 
90 /* ============================== ACCESSORS =============================== */
92 
93 
95 
96 /* =============================== INQUIRY ================================ */
98 
99 
101  int getTotalKeyLength();
102 
104  UtlBoolean getBinaryKey(char* buffer, int bufferLength);
105 
107  UtlString output() const;
108 
109 
111 
112 /* ////////////////////////////// PROTECTED /////////////////////////////// */
113 protected:
114 
115 
116 /* /////////////////////////////// PRIVATE //////////////////////////////// */
117 private:
118 
119  void clearKey();
120 
121  const EVP_CIPHER* const mpCipher;
122  const int mKeyLen;
123  const int mIvLen;
124  UtlCryptoData* mpKey;
125  UtlCryptoData* mpIv;
126 };
127 
128 
129 /* ============================ INLINE METHODS ============================ */
130 
131 
132 
133 #endif // _UtlCryptoKeyRsa_h_
A generic cryptography key base class.
Definition: UtlCryptoKey.h:36
A symmetric key implementation of UtlCryptoKey.
Definition: UtlCryptoKeySym.h:34
UtlCryptoData * getBinaryKey() const
Retrieves a binary key value (for later use by loadBinaryKey)
int decrypt(const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
Decrypts the given source data with the current key.
int getMaxEncryptedSize(int srcLen) const
Returns the max encrypted size of srcLen bytes from encrypt()
Crypto data operations.
Definition: UtlCryptoData.h:37
int getMaxDecryptedSize(int srcLen) const
Returns the max decrypted size of srcLen bytes from decrypt()
~UtlCryptoKeySym()
Destructor.
int generateKey()
Generates a new key.
Definition: UtlString.h:48
UtlCryptoKeySym()
Constructor.
int loadBinaryKey(const unsigned char *pSrc, int srcLen)
Loads a binary key value.
int UtlBoolean
Definition: UtlDefs.h:41
int getTotalKeyLength()
Return total key length.
int encrypt(const unsigned char *pSrc, int srcLen, unsigned char *pDest, int *pDestLen) const
Encrypts the given source data with the current key.
struct evp_cipher_st EVP_CIPHER
Definition: UtlCryptoKey.h:25
UtlString output() const
Get humane-readable describe.