1*12720SWyllys.Ingersoll@Sun.COM /*
2*12720SWyllys.Ingersoll@Sun.COM * CDDL HEADER START
3*12720SWyllys.Ingersoll@Sun.COM *
4*12720SWyllys.Ingersoll@Sun.COM * The contents of this file are subject to the terms of the
5*12720SWyllys.Ingersoll@Sun.COM * Common Development and Distribution License (the "License").
6*12720SWyllys.Ingersoll@Sun.COM * You may not use this file except in compliance with the License.
7*12720SWyllys.Ingersoll@Sun.COM *
8*12720SWyllys.Ingersoll@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12720SWyllys.Ingersoll@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*12720SWyllys.Ingersoll@Sun.COM * See the License for the specific language governing permissions
11*12720SWyllys.Ingersoll@Sun.COM * and limitations under the License.
12*12720SWyllys.Ingersoll@Sun.COM *
13*12720SWyllys.Ingersoll@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*12720SWyllys.Ingersoll@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12720SWyllys.Ingersoll@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*12720SWyllys.Ingersoll@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*12720SWyllys.Ingersoll@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*12720SWyllys.Ingersoll@Sun.COM *
19*12720SWyllys.Ingersoll@Sun.COM * CDDL HEADER END
20*12720SWyllys.Ingersoll@Sun.COM */
21*12720SWyllys.Ingersoll@Sun.COM
22*12720SWyllys.Ingersoll@Sun.COM /*
23*12720SWyllys.Ingersoll@Sun.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*12720SWyllys.Ingersoll@Sun.COM */
25*12720SWyllys.Ingersoll@Sun.COM
26*12720SWyllys.Ingersoll@Sun.COM /**
27*12720SWyllys.Ingersoll@Sun.COM * \file KMSAgentChallenge.cpp
28*12720SWyllys.Ingersoll@Sun.COM */
29*12720SWyllys.Ingersoll@Sun.COM
30*12720SWyllys.Ingersoll@Sun.COM #include "KMSAgentChallenge.h"
31*12720SWyllys.Ingersoll@Sun.COM #include "KMSAgentCryptoUtilities.h"
32*12720SWyllys.Ingersoll@Sun.COM #include "KMSAgentStringUtilities.h"
33*12720SWyllys.Ingersoll@Sun.COM #include "ApplianceParameters.h"
34*12720SWyllys.Ingersoll@Sun.COM #include "SYSCommon.h"
35*12720SWyllys.Ingersoll@Sun.COM
36*12720SWyllys.Ingersoll@Sun.COM extern "C" int Log2(char* msg1,
37*12720SWyllys.Ingersoll@Sun.COM char* msg2);
38*12720SWyllys.Ingersoll@Sun.COM
39*12720SWyllys.Ingersoll@Sun.COM #ifdef METAWARE
40*12720SWyllys.Ingersoll@Sun.COM #include "debug.h"
41*12720SWyllys.Ingersoll@Sun.COM #endif
42*12720SWyllys.Ingersoll@Sun.COM
43*12720SWyllys.Ingersoll@Sun.COM
44*12720SWyllys.Ingersoll@Sun.COM /**
45*12720SWyllys.Ingersoll@Sun.COM * ComputeChallengeResponse
46*12720SWyllys.Ingersoll@Sun.COM */
ComputeChallengeResponse(const unsigned char * i_pAuthenticationSecret,int i_iAuthenticationSecretLength,const unsigned char * i_pRootCACertificate,int i_iRootCACertificateLength,const unsigned char * i_pAuthenticationChallenge,int i_iAuthenticationChallengeLength,unsigned char * o_pAuthenticationChallengeResponse,int i_iAuthenticationChallengeResponseLength)47*12720SWyllys.Ingersoll@Sun.COM bool ComputeChallengeResponse(
48*12720SWyllys.Ingersoll@Sun.COM const unsigned char* i_pAuthenticationSecret,
49*12720SWyllys.Ingersoll@Sun.COM int i_iAuthenticationSecretLength,
50*12720SWyllys.Ingersoll@Sun.COM const unsigned char* i_pRootCACertificate,
51*12720SWyllys.Ingersoll@Sun.COM int i_iRootCACertificateLength,
52*12720SWyllys.Ingersoll@Sun.COM const unsigned char* i_pAuthenticationChallenge,
53*12720SWyllys.Ingersoll@Sun.COM int i_iAuthenticationChallengeLength,
54*12720SWyllys.Ingersoll@Sun.COM unsigned char* o_pAuthenticationChallengeResponse,
55*12720SWyllys.Ingersoll@Sun.COM int i_iAuthenticationChallengeResponseLength )
56*12720SWyllys.Ingersoll@Sun.COM {
57*12720SWyllys.Ingersoll@Sun.COM
58*12720SWyllys.Ingersoll@Sun.COM bool rc;
59*12720SWyllys.Ingersoll@Sun.COM
60*12720SWyllys.Ingersoll@Sun.COM #ifdef DEBUG
61*12720SWyllys.Ingersoll@Sun.COM Log2 ("KMSAgent_LoadProfile::ComputeChallengeResponse", "Entered");
62*12720SWyllys.Ingersoll@Sun.COM #endif
63*12720SWyllys.Ingersoll@Sun.COM FATAL_ASSERT( i_iAuthenticationChallengeResponseLength == HMAC_LENGTH );
64*12720SWyllys.Ingersoll@Sun.COM
65*12720SWyllys.Ingersoll@Sun.COM // challenge response is HMAC-SHA1( RootCACertificate ||
66*12720SWyllys.Ingersoll@Sun.COM // AuthenticationChallenge, AuthenticationSecret )
67*12720SWyllys.Ingersoll@Sun.COM const unsigned char* aBuffersToHMAC[2];
68*12720SWyllys.Ingersoll@Sun.COM int aBuffersToHMACSize[2];
69*12720SWyllys.Ingersoll@Sun.COM
70*12720SWyllys.Ingersoll@Sun.COM aBuffersToHMAC[0] = i_pRootCACertificate;
71*12720SWyllys.Ingersoll@Sun.COM aBuffersToHMACSize[0] = i_iRootCACertificateLength;
72*12720SWyllys.Ingersoll@Sun.COM
73*12720SWyllys.Ingersoll@Sun.COM aBuffersToHMAC[1] = i_pAuthenticationChallenge;
74*12720SWyllys.Ingersoll@Sun.COM aBuffersToHMACSize[1] = i_iAuthenticationChallengeLength;
75*12720SWyllys.Ingersoll@Sun.COM
76*12720SWyllys.Ingersoll@Sun.COM rc = HMACBuffers(
77*12720SWyllys.Ingersoll@Sun.COM 2,
78*12720SWyllys.Ingersoll@Sun.COM aBuffersToHMAC,
79*12720SWyllys.Ingersoll@Sun.COM aBuffersToHMACSize,
80*12720SWyllys.Ingersoll@Sun.COM i_pAuthenticationSecret,
81*12720SWyllys.Ingersoll@Sun.COM i_iAuthenticationSecretLength,
82*12720SWyllys.Ingersoll@Sun.COM o_pAuthenticationChallengeResponse );
83*12720SWyllys.Ingersoll@Sun.COM
84*12720SWyllys.Ingersoll@Sun.COM #if defined(METAWARE) && defined(DEBUG)
85*12720SWyllys.Ingersoll@Sun.COM int j=0;
86*12720SWyllys.Ingersoll@Sun.COM
87*12720SWyllys.Ingersoll@Sun.COM j+=snprintf(outmsg+j, OUTMSG_SIZE,
88*12720SWyllys.Ingersoll@Sun.COM "length=%x\n",
89*12720SWyllys.Ingersoll@Sun.COM i_iAuthenticationSecretLength);
90*12720SWyllys.Ingersoll@Sun.COM
91*12720SWyllys.Ingersoll@Sun.COM for (int i=0 ; i< i_iAuthenticationSecretLength; i++)
92*12720SWyllys.Ingersoll@Sun.COM {
93*12720SWyllys.Ingersoll@Sun.COM j+=snprintf(outmsg+j, OUTMSG_SIZE,
94*12720SWyllys.Ingersoll@Sun.COM "%x",
95*12720SWyllys.Ingersoll@Sun.COM i_pAuthenticationSecret[i]);
96*12720SWyllys.Ingersoll@Sun.COM }
97*12720SWyllys.Ingersoll@Sun.COM snprintf(outmsg+j, OUTMSG_SIZE, "\n");
98*12720SWyllys.Ingersoll@Sun.COM
99*12720SWyllys.Ingersoll@Sun.COM Log2("Secret = ",outmsg);
100*12720SWyllys.Ingersoll@Sun.COM #endif
101*12720SWyllys.Ingersoll@Sun.COM
102*12720SWyllys.Ingersoll@Sun.COM #if defined(METAWARE) && defined(DEBUG)
103*12720SWyllys.Ingersoll@Sun.COM j=0;
104*12720SWyllys.Ingersoll@Sun.COM
105*12720SWyllys.Ingersoll@Sun.COM j+=snprintf(outmsg+j, OUTMSG_SIZE,
106*12720SWyllys.Ingersoll@Sun.COM "length=%x\n",
107*12720SWyllys.Ingersoll@Sun.COM i_iRootCACertificateLength);
108*12720SWyllys.Ingersoll@Sun.COM
109*12720SWyllys.Ingersoll@Sun.COM for (i=0 ; i< i_iRootCACertificateLength; i++)
110*12720SWyllys.Ingersoll@Sun.COM {
111*12720SWyllys.Ingersoll@Sun.COM j+=snprintf(outmsg+j, OUTMSG_SIZE,
112*12720SWyllys.Ingersoll@Sun.COM "%x",
113*12720SWyllys.Ingersoll@Sun.COM i_pRootCACertificate[i]);
114*12720SWyllys.Ingersoll@Sun.COM }
115*12720SWyllys.Ingersoll@Sun.COM snprintf(outmsg+j, OUTMSG_SIZE, "\n");
116*12720SWyllys.Ingersoll@Sun.COM
117*12720SWyllys.Ingersoll@Sun.COM Log2("i_pRootCACertificate = ",outmsg);
118*12720SWyllys.Ingersoll@Sun.COM #endif
119*12720SWyllys.Ingersoll@Sun.COM
120*12720SWyllys.Ingersoll@Sun.COM #if defined(METAWARE) && defined(DEBUG)
121*12720SWyllys.Ingersoll@Sun.COM j=0;
122*12720SWyllys.Ingersoll@Sun.COM
123*12720SWyllys.Ingersoll@Sun.COM j+=snprintf(outmsg+j, OUTMSG_SIZE,
124*12720SWyllys.Ingersoll@Sun.COM "length=%x\n",
125*12720SWyllys.Ingersoll@Sun.COM i_iAuthenticationChallengeLength);
126*12720SWyllys.Ingersoll@Sun.COM
127*12720SWyllys.Ingersoll@Sun.COM for (i=0 ; i< i_iAuthenticationChallengeLength; i++)
128*12720SWyllys.Ingersoll@Sun.COM {
129*12720SWyllys.Ingersoll@Sun.COM j+=snprintf(outmsg+j, OUTMSG_SIZE,
130*12720SWyllys.Ingersoll@Sun.COM "%x",
131*12720SWyllys.Ingersoll@Sun.COM i_pAuthenticationChallenge[i]);
132*12720SWyllys.Ingersoll@Sun.COM }
133*12720SWyllys.Ingersoll@Sun.COM snprintf(outmsg+j, OUTMSG_SIZE, "\n");
134*12720SWyllys.Ingersoll@Sun.COM
135*12720SWyllys.Ingersoll@Sun.COM Log2("i_pAuthenticationChallenge = ",outmsg);
136*12720SWyllys.Ingersoll@Sun.COM #endif
137*12720SWyllys.Ingersoll@Sun.COM
138*12720SWyllys.Ingersoll@Sun.COM #if defined(METAWARE) && defined(DEBUG)
139*12720SWyllys.Ingersoll@Sun.COM j=0;
140*12720SWyllys.Ingersoll@Sun.COM
141*12720SWyllys.Ingersoll@Sun.COM j+=snprintf(outmsg+j, OUTMSG_SIZE,
142*12720SWyllys.Ingersoll@Sun.COM "length=%x\n",
143*12720SWyllys.Ingersoll@Sun.COM i_iAuthenticationChallengeResponseLength);
144*12720SWyllys.Ingersoll@Sun.COM
145*12720SWyllys.Ingersoll@Sun.COM for (i=0 ; i< i_iAuthenticationChallengeResponseLength; i++)
146*12720SWyllys.Ingersoll@Sun.COM {
147*12720SWyllys.Ingersoll@Sun.COM j+=snprintf(outmsg+j, OUTMSG_SIZE,
148*12720SWyllys.Ingersoll@Sun.COM "%x",
149*12720SWyllys.Ingersoll@Sun.COM o_pAuthenticationChallengeResponse[i]);
150*12720SWyllys.Ingersoll@Sun.COM }
151*12720SWyllys.Ingersoll@Sun.COM snprintf(outmsg+j, OUTMSG_SIZE, "\n");
152*12720SWyllys.Ingersoll@Sun.COM
153*12720SWyllys.Ingersoll@Sun.COM Log2("o_pAuthenticationChallengeResponse = ",outmsg);
154*12720SWyllys.Ingersoll@Sun.COM #endif
155*12720SWyllys.Ingersoll@Sun.COM
156*12720SWyllys.Ingersoll@Sun.COM return rc;
157*12720SWyllys.Ingersoll@Sun.COM
158*12720SWyllys.Ingersoll@Sun.COM #undef __IAM__
159*12720SWyllys.Ingersoll@Sun.COM }
160*12720SWyllys.Ingersoll@Sun.COM
161*12720SWyllys.Ingersoll@Sun.COM /**
162*12720SWyllys.Ingersoll@Sun.COM * ComputeEntityHashedPassphraseAndAuthenticationSecret
163*12720SWyllys.Ingersoll@Sun.COM */
ComputeEntityHashedPassphraseAndAuthenticationSecret(const char * i_sPassphrase,char * const o_sHexHashedPassphrase,int * const o_piAuthenticationHashIterationCount,char * const o_sHexAuthenticationSecret)164*12720SWyllys.Ingersoll@Sun.COM bool ComputeEntityHashedPassphraseAndAuthenticationSecret(
165*12720SWyllys.Ingersoll@Sun.COM const char* i_sPassphrase,
166*12720SWyllys.Ingersoll@Sun.COM char* const o_sHexHashedPassphrase,
167*12720SWyllys.Ingersoll@Sun.COM int* const o_piAuthenticationHashIterationCount,
168*12720SWyllys.Ingersoll@Sun.COM char* const o_sHexAuthenticationSecret )
169*12720SWyllys.Ingersoll@Sun.COM {
170*12720SWyllys.Ingersoll@Sun.COM // HashedPassphrase is SHA1( Passphrase-UTF-8 )
171*12720SWyllys.Ingersoll@Sun.COM // Using UTF-8 ensures the same result on different platforms with
172*12720SWyllys.Ingersoll@Sun.COM // different wide character representations.
173*12720SWyllys.Ingersoll@Sun.COM // This hashed passphrase value is used to wrap entity
174*12720SWyllys.Ingersoll@Sun.COM // private key materials.
175*12720SWyllys.Ingersoll@Sun.COM #if defined(METAWARE) && defined(DEBUG)
176*12720SWyllys.Ingersoll@Sun.COM Log2 ("KMSAgent_LoadProfile::ComputeEntityHashedPassphraseAndAuthenticationSecret",
177*12720SWyllys.Ingersoll@Sun.COM "Entered");
178*12720SWyllys.Ingersoll@Sun.COM #endif
179*12720SWyllys.Ingersoll@Sun.COM
180*12720SWyllys.Ingersoll@Sun.COM unsigned char aHashedPassphrase[HASH_LENGTH];
181*12720SWyllys.Ingersoll@Sun.COM
182*12720SWyllys.Ingersoll@Sun.COM memset(aHashedPassphrase, 0, HASH_LENGTH);
183*12720SWyllys.Ingersoll@Sun.COM
184*12720SWyllys.Ingersoll@Sun.COM if ( strlen(i_sPassphrase) > 0 )
185*12720SWyllys.Ingersoll@Sun.COM {
186*12720SWyllys.Ingersoll@Sun.COM if ( !HashBuffer(
187*12720SWyllys.Ingersoll@Sun.COM (unsigned char*)i_sPassphrase,
188*12720SWyllys.Ingersoll@Sun.COM strlen(i_sPassphrase),
189*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase) )
190*12720SWyllys.Ingersoll@Sun.COM {
191*12720SWyllys.Ingersoll@Sun.COM return false;
192*12720SWyllys.Ingersoll@Sun.COM }
193*12720SWyllys.Ingersoll@Sun.COM }
194*12720SWyllys.Ingersoll@Sun.COM
195*12720SWyllys.Ingersoll@Sun.COM ConvertBinaryToUTF8HexString( o_sHexHashedPassphrase,
196*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase,
197*12720SWyllys.Ingersoll@Sun.COM HASH_LENGTH );
198*12720SWyllys.Ingersoll@Sun.COM
199*12720SWyllys.Ingersoll@Sun.COM // HexAuthenticationSecret is SHA1( SHA1( ... ( SHA1(
200*12720SWyllys.Ingersoll@Sun.COM // HashedPassphrase ) ) ) The number of iterations is time bounded
201*12720SWyllys.Ingersoll@Sun.COM // at 1/10 of a second, and also bounded by fixed minimum and
202*12720SWyllys.Ingersoll@Sun.COM // maximum values (to prevent too weak of a computation and to
203*12720SWyllys.Ingersoll@Sun.COM // prevent a DoS, respectively). This value is used as the shared
204*12720SWyllys.Ingersoll@Sun.COM // secret in challenge-response authentication exchanges.
205*12720SWyllys.Ingersoll@Sun.COM
206*12720SWyllys.Ingersoll@Sun.COM *o_piAuthenticationHashIterationCount = 0;
207*12720SWyllys.Ingersoll@Sun.COM
208*12720SWyllys.Ingersoll@Sun.COM unsigned long iStartTickCount = K_GetTickCount();
209*12720SWyllys.Ingersoll@Sun.COM
210*12720SWyllys.Ingersoll@Sun.COM while ( *o_piAuthenticationHashIterationCount <
211*12720SWyllys.Ingersoll@Sun.COM MAX_AUTHENTICATION_ITERATION_COUNT
212*12720SWyllys.Ingersoll@Sun.COM && ( *o_piAuthenticationHashIterationCount <
213*12720SWyllys.Ingersoll@Sun.COM MIN_AUTHENTICATION_ITERATION_COUNT
214*12720SWyllys.Ingersoll@Sun.COM || iStartTickCount +
215*12720SWyllys.Ingersoll@Sun.COM AUTHENTICATION_ITERATION_TIME_IN_MILLISECONDS >
216*12720SWyllys.Ingersoll@Sun.COM K_GetTickCount() ) )
217*12720SWyllys.Ingersoll@Sun.COM {
218*12720SWyllys.Ingersoll@Sun.COM if ( !HashBuffer(
219*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase,
220*12720SWyllys.Ingersoll@Sun.COM HASH_LENGTH,
221*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase) )
222*12720SWyllys.Ingersoll@Sun.COM {
223*12720SWyllys.Ingersoll@Sun.COM return false;
224*12720SWyllys.Ingersoll@Sun.COM }
225*12720SWyllys.Ingersoll@Sun.COM
226*12720SWyllys.Ingersoll@Sun.COM (*o_piAuthenticationHashIterationCount)++;
227*12720SWyllys.Ingersoll@Sun.COM }
228*12720SWyllys.Ingersoll@Sun.COM
229*12720SWyllys.Ingersoll@Sun.COM ConvertBinaryToUTF8HexString( o_sHexAuthenticationSecret,
230*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase, HASH_LENGTH );
231*12720SWyllys.Ingersoll@Sun.COM
232*12720SWyllys.Ingersoll@Sun.COM #if defined(METAWARE) && defined(DEBUG)
233*12720SWyllys.Ingersoll@Sun.COM snprintf(outmsg, OUTMSG_SIZE,
234*12720SWyllys.Ingersoll@Sun.COM "o_sHexAuthenticationSecret=%x o_piAuth..."
235*12720SWyllys.Ingersoll@Sun.COM "= %x aHashedPassphrase=%s\n",
236*12720SWyllys.Ingersoll@Sun.COM o_sHexAuthenticationSecret,
237*12720SWyllys.Ingersoll@Sun.COM *o_piAuthenticationHashIterationCount,
238*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase);
239*12720SWyllys.Ingersoll@Sun.COM Log2("ComputeEntityHashedPassphraseAndAuthenticationSecret ",
240*12720SWyllys.Ingersoll@Sun.COM outmsg);
241*12720SWyllys.Ingersoll@Sun.COM #endif
242*12720SWyllys.Ingersoll@Sun.COM
243*12720SWyllys.Ingersoll@Sun.COM return true;
244*12720SWyllys.Ingersoll@Sun.COM }
245*12720SWyllys.Ingersoll@Sun.COM
246*12720SWyllys.Ingersoll@Sun.COM /**
247*12720SWyllys.Ingersoll@Sun.COM * ComputeFixedEntityHashedPassphraseAndAuthenticationSecret
248*12720SWyllys.Ingersoll@Sun.COM */
ComputeFixedEntityHashedPassphraseAndAuthenticationSecret(const char * i_sPassphrase,char * const o_sHexHashedPassphrase,int i_iAuthenticationHashIterationCount,char * const o_sHexAuthenticationSecret)249*12720SWyllys.Ingersoll@Sun.COM bool ComputeFixedEntityHashedPassphraseAndAuthenticationSecret(
250*12720SWyllys.Ingersoll@Sun.COM const char* i_sPassphrase,
251*12720SWyllys.Ingersoll@Sun.COM char* const o_sHexHashedPassphrase,
252*12720SWyllys.Ingersoll@Sun.COM int i_iAuthenticationHashIterationCount,
253*12720SWyllys.Ingersoll@Sun.COM char* const o_sHexAuthenticationSecret )
254*12720SWyllys.Ingersoll@Sun.COM {
255*12720SWyllys.Ingersoll@Sun.COM // compute same values as
256*12720SWyllys.Ingersoll@Sun.COM // ComputeEntityHashedPassphraseAndAuthenticationSecret, except
257*12720SWyllys.Ingersoll@Sun.COM // iteration count is fixed
258*12720SWyllys.Ingersoll@Sun.COM #if defined(METAWARE) && defined(DEBUG)
259*12720SWyllys.Ingersoll@Sun.COM Log2 ("KMSAgent_LoadProfile::"
260*12720SWyllys.Ingersoll@Sun.COM "ComputeFixedEntityHashedPassphraseAndAuthenticationSecret", "Entered");
261*12720SWyllys.Ingersoll@Sun.COM #endif
262*12720SWyllys.Ingersoll@Sun.COM
263*12720SWyllys.Ingersoll@Sun.COM // detect attempts to cause weak computation or DoS attack
264*12720SWyllys.Ingersoll@Sun.COM if ( i_iAuthenticationHashIterationCount <
265*12720SWyllys.Ingersoll@Sun.COM MIN_AUTHENTICATION_ITERATION_COUNT ||
266*12720SWyllys.Ingersoll@Sun.COM i_iAuthenticationHashIterationCount >
267*12720SWyllys.Ingersoll@Sun.COM MAX_AUTHENTICATION_ITERATION_COUNT )
268*12720SWyllys.Ingersoll@Sun.COM {
269*12720SWyllys.Ingersoll@Sun.COM return false;
270*12720SWyllys.Ingersoll@Sun.COM }
271*12720SWyllys.Ingersoll@Sun.COM
272*12720SWyllys.Ingersoll@Sun.COM
273*12720SWyllys.Ingersoll@Sun.COM unsigned char aHashedPassphrase[HASH_LENGTH];
274*12720SWyllys.Ingersoll@Sun.COM
275*12720SWyllys.Ingersoll@Sun.COM memset(aHashedPassphrase, 0, HASH_LENGTH);
276*12720SWyllys.Ingersoll@Sun.COM
277*12720SWyllys.Ingersoll@Sun.COM if ( strlen(i_sPassphrase) > 0 )
278*12720SWyllys.Ingersoll@Sun.COM {
279*12720SWyllys.Ingersoll@Sun.COM if ( !HashBuffer(
280*12720SWyllys.Ingersoll@Sun.COM (unsigned char*)i_sPassphrase,
281*12720SWyllys.Ingersoll@Sun.COM strlen(i_sPassphrase),
282*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase) )
283*12720SWyllys.Ingersoll@Sun.COM {
284*12720SWyllys.Ingersoll@Sun.COM return false;
285*12720SWyllys.Ingersoll@Sun.COM }
286*12720SWyllys.Ingersoll@Sun.COM }
287*12720SWyllys.Ingersoll@Sun.COM
288*12720SWyllys.Ingersoll@Sun.COM ConvertBinaryToUTF8HexString( o_sHexHashedPassphrase,
289*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase, HASH_LENGTH );
290*12720SWyllys.Ingersoll@Sun.COM
291*12720SWyllys.Ingersoll@Sun.COM int i;
292*12720SWyllys.Ingersoll@Sun.COM for ( i = 0; i < i_iAuthenticationHashIterationCount; i++ )
293*12720SWyllys.Ingersoll@Sun.COM {
294*12720SWyllys.Ingersoll@Sun.COM if ( !HashBuffer(
295*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase,
296*12720SWyllys.Ingersoll@Sun.COM HASH_LENGTH,
297*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase) )
298*12720SWyllys.Ingersoll@Sun.COM {
299*12720SWyllys.Ingersoll@Sun.COM return false;
300*12720SWyllys.Ingersoll@Sun.COM }
301*12720SWyllys.Ingersoll@Sun.COM }
302*12720SWyllys.Ingersoll@Sun.COM
303*12720SWyllys.Ingersoll@Sun.COM ConvertBinaryToUTF8HexString( o_sHexAuthenticationSecret,
304*12720SWyllys.Ingersoll@Sun.COM aHashedPassphrase, HASH_LENGTH );
305*12720SWyllys.Ingersoll@Sun.COM
306*12720SWyllys.Ingersoll@Sun.COM #if defined(METAWARE) && defined(DEBUG)
307*12720SWyllys.Ingersoll@Sun.COM snprintf(outmsg, OUTMSG_SIZE,
308*12720SWyllys.Ingersoll@Sun.COM "i_iAuth %x \n",
309*12720SWyllys.Ingersoll@Sun.COM i_iAuthenticationHashIterationCount);
310*12720SWyllys.Ingersoll@Sun.COM
311*12720SWyllys.Ingersoll@Sun.COM Log2("ComputeEntityHashedPassphraseAndAuthenticationSecret ",
312*12720SWyllys.Ingersoll@Sun.COM outmsg);
313*12720SWyllys.Ingersoll@Sun.COM #endif
314*12720SWyllys.Ingersoll@Sun.COM
315*12720SWyllys.Ingersoll@Sun.COM
316*12720SWyllys.Ingersoll@Sun.COM return true;
317*12720SWyllys.Ingersoll@Sun.COM }
318