]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_apple_csp/lib/RSA_DSA_utils.h
   2  * Copyright (c) 2000-2001,2011,2014 Apple Inc. All Rights Reserved. 
   4  * The contents of this file constitute Original Code as defined in and are 
   5  * subject to the Apple Public Source License Version 1.2 (the 'License'). 
   6  * You may not use this file except in compliance with the License. Please obtain 
   7  * a copy of the License at http://www.apple.com/publicsource and read it before 
  10  * This Original Code and all software distributed under the License are 
  11  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS 
  12  * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT 
  13  * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
  14  * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the 
  15  * specific language governing rights and limitations under the License. 
  22 #ifndef _RSA_DSA_UTILS_H_ 
  23 #define _RSA_DSA_UTILS_H_ 
  25 #include <openssl/rsa.h> 
  26 #include <openssl/dsa.h> 
  27 #include <AppleCSPSession.h> 
  28 #include <security_cdsa_utilities/context.h> 
  34 uint32 
rsaMaxKeySize(); 
  35 uint32 
rsaMaxPubExponentSize(); 
  39  * -- obtain CSSM key (there must only be one) 
  40  * -- validate keyClass 
  41  * -- validate keyUsage 
  42  * -- convert to RSA *, allocating the RSA key if necessary 
  45         const Context           
&context
, 
  46         AppleCSPSession         
&session
, 
  47         CSSM_KEYCLASS           keyClass
,         // CSSM_KEYCLASS_{PUBLIC,PRIVATE}_KEY 
  48         CSSM_KEYUSE                     usage
,            // CSSM_KEYUSE_ENCRYPT, CSSM_KEYUSE_SIGN, etc. 
  49         bool                            &mallocdKey
,  // RETURNED 
  50         CSSM_DATA                       
&label
);          // mallocd and RETURNED for OAEP 
  53  * Convert a CssmKey to an RSA * key. May result in the creation of a new 
  54  * RSA (when cssmKey is a raw key); allocdKey is true in that case 
  55  * in which case the caller generally has to free the allocd key). 
  58         const CssmKey   
&cssmKey
, 
  59         AppleCSPSession 
&session
, 
  60         bool                    &allocdKey
,             // RETURNED 
  61         CSSM_DATA               
&label
);                // mallocd and RETURNED for OAEP 
  64  * Convert a raw CssmKey to a newly alloc'd RSA *. 
  67         const CssmKey   
&cssmKey
, 
  68         CSSM_DATA               
&label
);                // mallocd and RETURNED for OAEP keys 
  71  * Given a partially formed DSA public key (with no p, q, or g) and a  
  72  * CssmKey representing a supposedly fully-formed DSA key, populate 
  73  * the public key's p, g, and q with values from the fully formed key. 
  75 CSSM_RETURN 
dsaGetParamsFromKey( 
  77         const CssmKey   
¶mKey
, 
  78         AppleCSPSession 
&session
); 
  82  * -- obtain CSSM key (there must only be one) 
  83  * -- validate keyClass 
  84  * -- validate keyUsage 
  85  * -- convert to DSA *, allocating the DSA key if necessary 
  88         const Context           
&context
, 
  89         AppleCSPSession         
&session
, 
  90         CSSM_KEYCLASS           keyClass
,         // CSSM_KEYCLASS_{PUBLIC,PRIVATE}_KEY 
  91         CSSM_KEYUSE                     usage
,            // CSSM_KEYUSE_ENCRYPT, CSSM_KEYUSE_SIGN, etc. 
  92         bool                            &mallocdKey
); // RETURNED 
  95  * Convert a CssmKey to an DSA * key. May result in the creation of a new 
  96  * DSA (when cssmKey is a raw key); allocdKey is true in that case 
  97  * in which case the caller generally has to free the allocd key). 
 100         const CssmKey   
&cssmKey
, 
 101         AppleCSPSession 
&session
, 
 102         bool                    &allocdKey
);    // RETURNED 
 105  * Convert a raw CssmKey to a newly alloc'd DSA *. 
 107 DSA 
*rawCssmKeyToDsa( 
 108         const CssmKey   
&cssmKey
, 
 109         AppleCSPSession 
&session
, 
 110         const CssmKey   
*paramKey
);             // optional 
 113  * Given a DSA private key, calculate its public component if it  
 114  * doesn't already exist. Used for calculating the key digest of  
 115  * an incoming raw private key. 
 117 void dsaKeyPrivToPub( 
 124 #endif  /*_RSA_DSA_UTILS_H_ */