1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 /*
21  * XSEC
22  *
23  * XSECCryptoKey := Container class to hold cryptographic keys
24  *					Should be re-implemented by all providers as the base class
25  *                  for all keys
26  *
27  * Author(s): Berin Lautenbach
28  *
29  * $Id: XSECCryptoKey.hpp 1817863 2017-12-11 22:47:43Z scantor $
30  *
31  */
32 
33 
34 
35 #ifndef XSECCRYPTOKEY_INCLUDE
36 #define XSECCRYPTOKEY_INCLUDE
37 
38 #include <xsec/framework/XSECDefs.hpp>
39 
40 /**
41  * \ingroup crypto
42  */
43 
44 /**
45  * \brief Base interface class for key material.
46  *
47  * All keys used for signing and encrypting are derived from this
48  * base interface class.  There are no methods for performing
49  * cryptographic functions, as this is a base class used to allow
50  * the library to pass key material to various objects without
51  * knowing how to directly use it.
52  */
53 
54 class XSEC_EXPORT XSECCryptoKey {
55 
56 public :
57 
58 	/**
59 	 * \brief Key types understood by the library
60 	 *
61 	 * This type defines the list of key types that the library
62 	 * understands.
63 	 */
64 
65 	enum KeyType {
66 
67 		KEY_NONE,
68 		KEY_DSA_PUBLIC,
69 		KEY_DSA_PRIVATE,
70 		KEY_DSA_PAIR,
71 		KEY_RSA_PUBLIC,
72 		KEY_RSA_PRIVATE,
73 		KEY_RSA_PAIR,
74 		KEY_HMAC,
75 		KEY_SYMMETRIC,
76 		KEY_EC_PUBLIC,
77 		KEY_EC_PRIVATE,
78 		KEY_EC_PAIR
79 
80 	};
81 
82 
83 	/** @name Constructors and Destructors */
84 	//@{
85 
86 	/**
87 	 * \brief Constructor
88 	 **/
89 
XSECCryptoKey()90 	XSECCryptoKey() {};
91 
92 	/**
93 	 * \brief Destructor
94 	 *
95 	 * Implementations must ensure that the held key is properly destroyed
96 	 * (overwritten) when key objects are deleted.
97 	 */
98 
~XSECCryptoKey()99 	virtual ~XSECCryptoKey() {};
100 
101 	//@}
102 
103 	/** @name Interface classes */
104 	//@{
105 
106 	/**
107 	 * \brief Returns the type of this key.
108 	 */
109 
getKeyType() const110 	virtual KeyType getKeyType() const {return KEY_NONE;}
111 
112 	/**
113 	 * \brief Returns a string that identifies the crypto owner of this library.
114 	 */
115 
116 	virtual const XMLCh * getProviderName() const = 0;
117 
118 	/**
119 	 * \brief Clone the key
120 	 *
121 	 * All keys need to be able to copy themselves and return
122 	 * a pointer to the copy.  This allows the library to
123 	 * duplicate keys.
124 	 */
125 
126 	virtual XSECCryptoKey * clone() const = 0;
127 
128   //@}
129 
130 };
131 
132 
133 #endif /* XSECCRYPTOKEY_INCLUDE */
134