]>
git.saurik.com Git - apple/security.git/blob - libsecurity_apple_csp/lib/SHA2_Object.cpp
   2  * Copyright (c) 2000-2004 Apple Computer, 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  
  27  * Created 8/12/2004 by dmitch. 
  28  * Created 2/19/2001 by dmitch. 
  31 #include "SHA2_Object.h" 
  38 void SHA224Object::digestInit() 
  41         CC_SHA224_Init(&mCtx
); 
  44 void SHA224Object::digestUpdate( 
  48         CC_SHA224_Update(&mCtx
, (const unsigned char *)data
, len
); 
  51 void SHA224Object::digestFinal( 
  54         CC_SHA224_Final((unsigned char *)digest
, &mCtx
); 
  58 /* use default memberwise init */ 
  59 DigestObject 
*SHA224Object::digestClone() const 
  61         return new SHA224Object(*this); 
  64 size_t SHA224Object::digestSizeInBytes() const 
  66         return CC_SHA224_DIGEST_LENGTH
; 
  72 void SHA256Object::digestInit() 
  75         CC_SHA256_Init(&mCtx
); 
  78 void SHA256Object::digestUpdate( 
  82         CC_SHA256_Update(&mCtx
, (const unsigned char *)data
, len
); 
  85 void SHA256Object::digestFinal( 
  88         CC_SHA256_Final((unsigned char *)digest
, &mCtx
); 
  92 /* use default memberwise init */ 
  93 DigestObject 
*SHA256Object::digestClone() const 
  95         return new SHA256Object(*this); 
  98 size_t SHA256Object::digestSizeInBytes() const 
 100         return CC_SHA256_DIGEST_LENGTH
; 
 106 void SHA384Object::digestInit() 
 109         CC_SHA384_Init(&mCtx
); 
 112 void SHA384Object::digestUpdate( 
 116         CC_SHA384_Update(&mCtx
, (const unsigned char *)data
, len
); 
 119 void SHA384Object::digestFinal( 
 122         CC_SHA384_Final((unsigned char *)digest
, &mCtx
); 
 126 /* use default memberwise init */ 
 127 DigestObject 
*SHA384Object::digestClone() const 
 129         return new SHA384Object(*this); 
 132 size_t SHA384Object::digestSizeInBytes() const 
 134         return CC_SHA384_DIGEST_LENGTH
; 
 140 void SHA512Object::digestInit() 
 143         CC_SHA512_Init(&mCtx
); 
 146 void SHA512Object::digestUpdate( 
 150         CC_SHA512_Update(&mCtx
, (const unsigned char *)data
, len
); 
 153 void SHA512Object::digestFinal( 
 156         CC_SHA512_Final((unsigned char *)digest
, &mCtx
); 
 160 /* use default memberwise init */ 
 161 DigestObject 
*SHA512Object::digestClone() const 
 163         return new SHA512Object(*this); 
 166 size_t SHA512Object::digestSizeInBytes() const 
 168         return CC_SHA512_DIGEST_LENGTH
;