File: WinCAPICryptoSymmetricKey_8hpp-source.html

package info (click to toggle)
xml-security-c 1.2.1-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 24,464 kB
  • ctags: 6,673
  • sloc: cpp: 36,830; xml: 23,415; sh: 2,365; makefile: 340; perl: 221
file content (145 lines) | stat: -rw-r--r-- 12,875 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>XML-Security-C: WinCAPICryptoSymmetricKey.hpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.2 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">src</a>&nbsp;/&nbsp;<a class="el" href="dir_000002.html">enc</a>&nbsp;/&nbsp;<a class="el" href="dir_000005.html">WinCAPI</a></div>
<h1>WinCAPICryptoSymmetricKey.hpp</h1><a href="WinCAPICryptoSymmetricKey_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
00002 <span class="comment"> * Copyright 2002-2005 The Apache Software Foundation.</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span>
00005 <span class="comment"> * you may not use this file except in compliance with the License.</span>
00006 <span class="comment"> * You may obtain a copy of the License at</span>
00007 <span class="comment"> *</span>
00008 <span class="comment"> *     http://www.apache.org/licenses/LICENSE-2.0</span>
00009 <span class="comment"> *</span>
00010 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
00011 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
00012 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
00013 <span class="comment"> * See the License for the specific language governing permissions and</span>
00014 <span class="comment"> * limitations under the License.</span>
00015 <span class="comment"> */</span>
00016 
00017 <span class="comment">/*</span>
00018 <span class="comment"> * XSEC</span>
00019 <span class="comment"> *</span>
00020 <span class="comment"> * XSECCryptoSymmetricKey := Bulk encryption algorithms should all be</span>
00021 <span class="comment"> *                          implemented via this interface</span>
00022 <span class="comment"> *</span>
00023 <span class="comment"> * Author(s): Berin Lautenbach</span>
00024 <span class="comment"> *</span>
00025 <span class="comment"> * $Id: WinCAPICryptoSymmetricKey.hpp,v 1.7 2005/06/04 11:30:26 blautenb Exp $</span>
00026 <span class="comment"> *</span>
00027 <span class="comment"> */</span>
00028 
00029 
00030 
00031 <span class="preprocessor">#ifndef WINCAPICRYPTOSYMMETRICKEY_INCLUDE</span>
00032 <span class="preprocessor"></span><span class="preprocessor">#define WINCAPICRYPTOSYMMETRICKEY_INCLUDE</span>
00033 <span class="preprocessor"></span>
00034 <span class="preprocessor">#include &lt;xsec/framework/XSECDefs.hpp&gt;</span>
00035 <span class="preprocessor">#include &lt;xsec/enc/XSECCryptoSymmetricKey.hpp&gt;</span>
00036 
00037 <span class="preprocessor">#if defined (HAVE_WINCAPI)</span>
00038 <span class="preprocessor"></span>
00039 <span class="preprocessor">#if !defined(_WIN32_WINNT)</span>
<a name="l00040"></a><a class="code" href="WinCAPICryptoSymmetricKey_8hpp.html#a0">00040</a> <span class="preprocessor"></span><span class="preprocessor">#   define _WIN32_WINNT 0x0400</span>
00041 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00042 <span class="preprocessor"></span>
00043 <span class="preprocessor">#include &lt;wincrypt.h&gt;</span>
00044 
<a name="l00045"></a><a class="code" href="WinCAPICryptoSymmetricKey_8hpp.html#a1">00045</a> <span class="preprocessor">#define WINCAPI_MAX_BLOCK_SIZE      32</span>
00046 <span class="preprocessor"></span>
<a name="l00058"></a><a class="code" href="classWinCAPICryptoSymmetricKey.html">00058</a> <span class="keyword">class </span><a class="code" href="XSECDefs_8hpp.html#a9">DSIG_EXPORT</a> <a class="code" href="classWinCAPICryptoSymmetricKey.html">WinCAPICryptoSymmetricKey</a> : <span class="keyword">public</span> <a class="code" href="classXSECCryptoSymmetricKey.html">XSECCryptoSymmetricKey</a> {
00059 
00060 <span class="keyword">public</span> :
00061 
00064     
00076     <a class="code" href="classWinCAPICryptoSymmetricKey.html">WinCAPICryptoSymmetricKey</a>(HCRYPTPROV prov, <a class="code" href="classXSECCryptoSymmetricKey.html#w8">XSECCryptoSymmetricKey::SymmetricKeyType</a> type);
00077 
00085     <span class="keyword">virtual</span> ~<a class="code" href="classWinCAPICryptoSymmetricKey.html">WinCAPICryptoSymmetricKey</a>();
00086 
00088 
00091 
00096     <span class="keyword">virtual</span> <span class="keyword">const</span> XMLCh * <a class="code" href="classXSECCryptoSymmetricKey.html#z176_1">getProviderName</a>();
00097 
00106     <span class="keyword">virtual</span> <a class="code" href="classXSECCryptoKey.html">XSECCryptoKey</a> * <a class="code" href="classXSECCryptoSymmetricKey.html#z176_2">clone</a>();
00107 
00109 
00112 
00121     SymmetricKeyType <a class="code" href="classXSECCryptoSymmetricKey.html#z177_0">getSymmetricKeyType</a>(<span class="keywordtype">void</span>);
00122 
00134     <span class="keywordtype">void</span> <a class="code" href="classXSECCryptoSymmetricKey.html#z177_1">setKey</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> keyLen);
00135 
00152     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classXSECCryptoSymmetricKey.html#z177_2">decryptInit</a>(<span class="keywordtype">bool</span> doPad = <span class="keyword">true</span>,
00153                              SymmetricKeyMode mode = MODE_CBC,
00154                              <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * iv = NULL);
00155 
00180     <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classXSECCryptoSymmetricKey.html#z177_3">decrypt</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * inBuf, 
00181                                  <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * plainBuf, 
00182                                  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> inLength,
00183                                  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> maxOutLength);
00184 
00204     <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classXSECCryptoSymmetricKey.html#z177_4">decryptFinish</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * plainBuf,
00205                                        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> maxOutLength);
00206 
00222     <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classXSECCryptoSymmetricKey.html#z177_5">encryptInit</a>(<span class="keywordtype">bool</span> doPad = <span class="keyword">true</span>, 
00223                              SymmetricKeyMode mode = MODE_CBC,
00224                              <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * iv = NULL);
00225 
00246     <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classXSECCryptoSymmetricKey.html#z177_6">encrypt</a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * inBuf, 
00247                                  <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * cipherBuf, 
00248                                  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> inLength,
00249                                  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> maxOutLength);
00250 
00272     <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classXSECCryptoSymmetricKey.html#z177_7">encryptFinish</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * plainBuf,
00273                                        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> maxOutLength);
00274 
00276 
00279 
00298     <span class="keyword">static</span> HCRYPTKEY createWindowsKey(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * key, 
00299                                       <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> keyLen, 
00300                                       <a class="code" href="classXSECCryptoSymmetricKey.html#w8">XSECCryptoSymmetricKey::SymmetricKeyType</a> type,
00301                                       HCRYPTPROV * prov);
00302 
00303 
00304 
00305 <span class="keyword">private</span>:
00306 
00307     <span class="comment">// Unimplemented constructors</span>
00308     
00309     <a class="code" href="classWinCAPICryptoSymmetricKey.html">WinCAPICryptoSymmetricKey</a>();
00310     <a class="code" href="classWinCAPICryptoSymmetricKey.html">WinCAPICryptoSymmetricKey</a>(<span class="keyword">const</span> <a class="code" href="classWinCAPICryptoSymmetricKey.html">WinCAPICryptoSymmetricKey</a> &amp;);
00311     <a class="code" href="classWinCAPICryptoSymmetricKey.html">WinCAPICryptoSymmetricKey</a> &amp; operator= (<span class="keyword">const</span> <a class="code" href="classWinCAPICryptoSymmetricKey.html">WinCAPICryptoSymmetricKey</a> &amp;);
00312 
00313     <span class="keywordtype">int</span> decryptCtxInit(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * iv);
00314     <span class="keywordtype">void</span> encryptCtxInit(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * iv);
00315 
00316     <span class="comment">// Private variables</span>
00317     SymmetricKeyType                m_keyType;
00318     SymmetricKeyMode                m_keyMode;      <span class="comment">// ECB or CBC</span>
00319     <a class="code" href="classsafeBuffer.html">safeBuffer</a>                      m_keyBuf;       <span class="comment">// Holder of the key</span>
00320     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                    m_keyLen;
00321     <span class="keywordtype">bool</span>                            m_initialised;
00322     <span class="keywordtype">bool</span>                            m_doPad;
00323 
00324     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>                   m_lastBlock[<a class="code" href="WinCAPICryptoSymmetricKey_8hpp.html#a1">WINCAPI_MAX_BLOCK_SIZE</a>];
00325     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                    m_bytesInLastBlock;
00326     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                    m_blockSize;
00327     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>                    m_ivSize;
00328 
00329     HCRYPTPROV                      m_p;
00330     HCRYPTKEY                       m_k;
00331 
00332 };
00333 
00334 <span class="preprocessor">#endif </span><span class="comment">/* HAVE_WINCAPI */</span>
00335 <span class="preprocessor">#endif </span><span class="comment">/* WINCAPICRYPTOSYMMETRICKEY_INCLUDE */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Jul 3 17:37:26 2005 for XML-Security-C by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
</body>
</html>