]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/cspxutils/utilLib/bsafeUtils.h
2 * bsafeUtils.h - common routines for CDSA/BSAFE compatibility testing
6 * Clients of this module do not need to know about or see anything from the
9 #ifndef _BSAFE_UTILS_H_
10 #define _BSAFE_UTILS_H_
11 #include <Security/cssmtype.h>
17 /* Actually the same as a B_KEY_OBJ, but our callers don't need to know that */
21 * Create a symmetric key.
23 CSSM_RETURN
buGenSymKey(
25 const CSSM_DATA
*keyData
,
26 BU_KEY
*key
); // RETURNED
29 * Create asymmetric key pair.
30 * FIXME - additional params (e.g. DSA params, RSA exponent)?
32 CSSM_RETURN
buGenKeyPair(
34 CSSM_ALGORITHMS keyAlg
, // CSSM_ALGID_{RSA,DSA}
35 BU_KEY
*pubKey
, // RETURNED
36 BU_KEY
*privKey
); // RETURNED
39 * Free a key created in buGenSymKey or buGenKeyPair
41 CSSM_RETURN
buFreeKey(
47 CSSM_RETURN
buEncryptDecrypt(
50 CSSM_ALGORITHMS encrAlg
,
51 CSSM_ENCRYPT_MODE mode
, // CSSM_ALGMODE_CBC, etc.
52 const CSSM_DATA
*iv
, //ĂŠoptional per mode
53 uint32 effectiveKeyBits
, // optional per key alg (actually just RC2)
54 // for RSA, key size in bits
55 uint32 rounds
, // optional, RC5 only
56 const CSSM_DATA
*inData
,
57 CSSM_DATA_PTR outData
); // mallocd and RETURNED
64 CSSM_ALGORITHMS sigAlg
,
65 const CSSM_DATA
*ptext
,
66 uint32 keySizeInBits
, // to set up sig
67 CSSM_DATA_PTR sig
); // mallocd and RETURNED
71 CSSM_ALGORITHMS sigAlg
,
72 const CSSM_DATA
*ptext
,
73 const CSSM_DATA
*sig
); // mallocd and RETURNED
76 * generate MAC either one update (updateSizes == NULL) or
77 * specified set of update sizes.
80 BU_KEY key
, // any key, any size
81 CSSM_ALGORITHMS macAlg
, // only CSSM_ALGID_SHA1HMAC for now
82 const CSSM_DATA
*ptext
,
83 unsigned *updateSizes
, // NULL --> random updates
84 // else null-terminated list of sizes
85 CSSM_DATA_PTR mac
); // mallocd and RETURNED
88 CSSM_RETURN
buGenDigest(
89 CSSM_ALGORITHMS macAlg
, // CSSM_ALGID_SHA1, etc. */
90 const CSSM_DATA
*ptext
,
91 CSSM_DATA_PTR digest
); // mallocd and RETURNED
94 * Convert between BSAFE and CDSA private keys
96 CSSM_RETURN
buBsafePrivKeyToCdsa(
97 CSSM_ALGORITHMS keyAlg
,
100 CSSM_KEY_PTR cdsaPrivKey
);
101 CSSM_RETURN
buCdsaPrivKeyToBsafe(
102 CSSM_KEY_PTR cdsaPrivKey
,
103 BU_KEY
*bsafePrivKey
);
109 #endif /* _BSAFE_UTILS_H_ */