]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_apple_csp/lib/SHA2_Object.cpp
2 * Copyright (c) 2000-2004,2011-2012,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 * SHA2_Object.cpp - SHA2 digest objects
29 #include "SHA2_Object.h"
36 void SHA224Object::digestInit()
39 CC_SHA224_Init(&mCtx
);
42 void SHA224Object::digestUpdate(
46 CC_SHA224_Update(&mCtx
, (const unsigned char *)data
, (CC_LONG
)len
);
49 void SHA224Object::digestFinal(
52 CC_SHA224_Final((unsigned char *)digest
, &mCtx
);
56 /* use default memberwise init */
57 DigestObject
*SHA224Object::digestClone() const
59 return new SHA224Object(*this);
62 size_t SHA224Object::digestSizeInBytes() const
64 return CC_SHA224_DIGEST_LENGTH
;
70 void SHA256Object::digestInit()
73 CC_SHA256_Init(&mCtx
);
76 void SHA256Object::digestUpdate(
80 CC_SHA256_Update(&mCtx
, (const unsigned char *)data
, (CC_LONG
)len
);
83 void SHA256Object::digestFinal(
86 CC_SHA256_Final((unsigned char *)digest
, &mCtx
);
90 /* use default memberwise init */
91 DigestObject
*SHA256Object::digestClone() const
93 return new SHA256Object(*this);
96 size_t SHA256Object::digestSizeInBytes() const
98 return CC_SHA256_DIGEST_LENGTH
;
104 void SHA384Object::digestInit()
107 CC_SHA384_Init(&mCtx
);
110 void SHA384Object::digestUpdate(
114 CC_SHA384_Update(&mCtx
, (const unsigned char *)data
, (CC_LONG
)len
);
117 void SHA384Object::digestFinal(
120 CC_SHA384_Final((unsigned char *)digest
, &mCtx
);
124 /* use default memberwise init */
125 DigestObject
*SHA384Object::digestClone() const
127 return new SHA384Object(*this);
130 size_t SHA384Object::digestSizeInBytes() const
132 return CC_SHA384_DIGEST_LENGTH
;
138 void SHA512Object::digestInit()
141 CC_SHA512_Init(&mCtx
);
144 void SHA512Object::digestUpdate(
148 CC_SHA512_Update(&mCtx
, (const unsigned char *)data
, (CC_LONG
)len
);
151 void SHA512Object::digestFinal(
154 CC_SHA512_Final((unsigned char *)digest
, &mCtx
);
158 /* use default memberwise init */
159 DigestObject
*SHA512Object::digestClone() const
161 return new SHA512Object(*this);
164 size_t SHA512Object::digestSizeInBytes() const
166 return CC_SHA512_DIGEST_LENGTH
;