1 #ifndef __TRANSFORM_SIGN_VERIFY__ 
   2 #define __TRANSFORM_SIGN_VERIFY__ 
   6  * Copyright (c) 2010-2011 Apple Inc. All Rights Reserved. 
   8  * @APPLE_LICENSE_HEADER_START@ 
  10  * This file contains Original Code and/or Modifications of Original Code 
  11  * as defined in and that are subject to the Apple Public Source License 
  12  * Version 2.0 (the 'License'). You may not use this file except in 
  13  * compliance with the License. Please obtain a copy of the License at 
  14  * http://www.opensource.apple.com/apsl/ and read it before using this 
  17  * The Original Code and all software distributed under the License are 
  18  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  19  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  20  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  21  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  22  * Please see the License for the specific language governing rights and 
  23  * limitations under the License. 
  25  * @APPLE_LICENSE_HEADER_END@ 
  28 #include "SecTransform.h" 
  29 #include <Security/SecBase.h> 
  36     CF_ASSUME_NONNULL_BEGIN
 
  37     CF_IMPLICIT_BRIDGING_ENABLED
 
  39         extern const CFStringRef kSecKeyAttributeName
, kSecSignatureAttributeName
, kSecInputIsAttributeName
; 
  40         // WARNING: kSecInputIsRaw is frequently cryptographically unsafe (for example if you don't blind a DSA or ECDSA signature you give away the key very quickly), please only use it if you really know the math. 
  41         extern const CFStringRef kSecInputIsPlainText
, kSecInputIsDigest
, kSecInputIsRaw
; 
  42         // Supported optional attributes: kSecDigestTypeAttribute (kSecDigestMD2, kSecDigestMD4, kSecDigestMD5, kSecDigestSHA1, kSecDigestSHA2), kSecDigestLengthAttribute 
  45          @function SecSignTransformCreate 
  46          @abstract                      Creates a sign computation object. 
  47          @param key             A SecKey with the private key used for signing. 
  48          @param error           A pointer to a CFErrorRef.  This pointer will be set 
  49          if an error occurred.  This value may be NULL if you 
  50          do not want an error returned. 
  51          @result                                A pointer to a SecTransformRef object.  This object must 
  52          be released with CFRelease when you are done with 
  53          it.  This function will return NULL if an error 
  55          @discussion                    This function creates a transform which computes a 
  56          cryptographic signature.   The InputIS defaults to kSecInputIsPlainText, 
  57          and the DigestType and DigestLength default to something appropriate for 
  58          the type of key you have supplied. 
  62         SecTransformRef 
SecSignTransformCreate(SecKeyRef key
, 
  65         __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
); 
  68          @function SecVerifyTransformCreate 
  69          @abstract                      Creates a verify computation object. 
  70          @param key             A SecKey with the public key used for signing. 
  71          @param signature       A CFDataRef with the signature.   This value may be 
  72          NULL, and you may connect a transform to kSecTransformSignatureAttributeName 
  73          to supply it from another signature. 
  74          @param error           A pointer to a CFErrorRef.  This pointer will be set 
  75          if an error occurred.  This value may be NULL if you 
  76          do not want an error returned. 
  77          @result                                A pointer to a SecTransformRef object.  This object must 
  78          be released with CFRelease when you are done with 
  79          it.  This function will return NULL if an error 
  81          @discussion                    This function creates a transform which verifies a 
  82          cryptographic signature.  The InputIS defaults to kSecInputIsPlainText, 
  83          and the DigestType and DigestLength default to something appropriate for 
  84          the type of key you have supplied. 
  88         SecTransformRef 
SecVerifyTransformCreate(SecKeyRef key
, 
  89                                                                                          CFDataRef __nullable signature
, 
  92         __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_NA
); 
  94     CF_IMPLICIT_BRIDGING_DISABLED