#include <Security/oidsalg.h>
#include <Security/oidscert.h>
-#pragma mark -
-#pragma mark Utilities
+// MARK: -
+// MARK: Utilities
/*
* Set up a Raw symmetric key with specified algorithm and key bits.
hdr->KeyAttr = CSSM_KEYATTR_MODIFIABLE | CSSM_KEYATTR_EXTRACTABLE;
hdr->KeyUsage = keyUse;
hdr->WrapAlgorithmId = CSSM_ALGID_NONE;
- return noErr;
+ return errSecSuccess;
}
/*
*kcItem = NULL;
}
#endif
- return noErr;
+ return errSecSuccess;
}
/*
{
assert(ctx != NULL);
if(ctx->cspHand != 0) {
- return noErr;
+ return errSecSuccess;
}
else {
return errSSLModuleAttach;
{
assert(ctx != NULL);
if(ctx->clHand != 0) {
- return noErr;
+ return errSecSuccess;
}
else {
return errSSLModuleAttach;
{
assert(ctx != NULL);
if(ctx->tpHand != 0) {
- return noErr;
+ return errSecSuccess;
}
else {
return errSSLModuleAttach;
return errSSLModuleAttach;
}
else {
- return noErr;
+ return errSecSuccess;
}
}
ctx->clHand = 0;
}
#endif /* 0 */
- return noErr;
+ return errSecSuccess;
}
/*
return NULL;
}
-#pragma mark -
-#pragma mark CSSM_DATA routines
+// MARK: -
+// MARK: CSSM_DATA routines
CSSM_DATA_PTR stMallocCssmData(
size_t size)
if(data->Length == 0) {
data->Data = (uint8 *)stAppMalloc(length, NULL);
if(data->Data == NULL) {
- return memFullErr;
+ return errSecAllocate;
}
}
else if(data->Length < length) {
sslErrorLog("stSetUpCssmData: length too small\n");
- return memFullErr;
+ return errSecAllocate;
}
data->Length = length;
- return noErr;
+ return errSecSuccess;
}
/* All signature ops are "raw", with digest step done by us */
CSSM_ALGORITHMS *sigAlg) /* RETURNED */
{
- OSStatus ortn = noErr;
+ OSStatus ortn = errSecSuccess;
switch(cssmKey->KeyHeader.AlgorithmId) {
case CSSM_ALGID_RSA:
*sigAlg = CSSM_ALGID_RSA;
return ortn;
}
-#pragma mark -
-#pragma mark Public CSP Functions
+// MARK: -
+// MARK: Public CSP Functions
/*
* Raw RSA/DSA sign/verify.
}
else {
*actualBytes = sigData.Length;
- serr = noErr;
+ serr = errSecSuccess;
}
if(sigHand != 0) {
CSSM_DeleteContext(sigHand);
serr = errSSLCrypto;
}
else {
- serr = noErr;
+ serr = errSecSuccess;
}
if(sigHand != 0) {
CSSM_DeleteContext(sigHand);
memmove(cipherText + toMoveCtext, remData.Data,
toMoveRem);
}
- serr = noErr;
+ serr = errSecSuccess;
}
}
else {
memmove(plainText + toMovePtext, remData.Data,
toMoveRem);
}
- serr = noErr;
+ serr = errSecSuccess;
}
}
else {
const CSSM_KEY *privKey,
uint32_t *maxSigSize)
{
- OSStatus ortn = noErr;
+ OSStatus ortn = errSecSuccess;
assert(privKey != NULL);
assert(privKey->KeyHeader.KeyClass == CSSM_KEYCLASS_PRIVATE_KEY);
switch(privKey->KeyHeader.AlgorithmId) {
/* the rest is boilerplate, cook up a good-looking public key */
key = (CSSM_KEY_PTR)sslMalloc(sizeof(CSSM_KEY));
if(key == NULL) {
- return memFullErr;
+ return errSecAllocate;
}
memset(key, 0, sizeof(CSSM_KEY));
hdr = &key->KeyHeader;
hdr->LogicalKeySizeInBits = keySize.EffectiveKeySizeInBits;
*pubKey = key;
*cspHand = ctx->cspHand;
- return noErr;
+ return errSecSuccess;
abort:
/* note this frees the blob */
CSSM_ACCESS_CREDENTIALS creds;
CSSM_DATA labelData = {4, (uint8 *)"none"};
uint32 keyAttr;
- OSStatus ortn = noErr;
+ OSStatus ortn = errSecSuccess;
memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS));
memset(refKey, 0, sizeof(CSSM_KEY));
CSSM_CC_HANDLE ccHand;
CSSM_ACCESS_CREDENTIALS creds;
uint32 keyAttr;
- OSStatus ortn = noErr;
+ OSStatus ortn = errSecSuccess;
memset(&creds, 0, sizeof(CSSM_ACCESS_CREDENTIALS));
memset(rawKey, 0, sizeof(CSSM_KEY));
return crtn;
}
-#pragma mark -
-#pragma mark Public Certificate Functions
+// MARK: -
+// MARK: Public Certificate Functions
/*
* Given a DER-encoded cert, obtain its public key as a CSSM_KEY_PTR.
}
else {
pubKey->cspHand = ctx->cspHand;
- return noErr;
+ return errSecSuccess;
}
}
CFMutableArrayRef certGroup = CFArrayCreateMutable(NULL, numCerts,
&kCFTypeArrayCallBacks);
if(certGroup == NULL) {
- return memFullErr;
+ return errSecAllocate;
}
/* subsequent errors to errOut: */
kcList = CFArrayCreateMutable(NULL, 0, NULL);
if(kcList == NULL) {
sslErrorLog("***sslVerifyCertChain: error creating null kcList\n");
- serr = memFullErr;
+ serr = errSecAllocate;
goto errOut;
}
serr = SecTrustSetKeychains(theTrust, kcList);
if(!ctx->enableCertVerify) {
/* trivial case, this is caller's responsibility */
- serr = noErr;
+ serr = errSecSuccess;
goto errOut;
}
if(ctx->trustedLeafCerts) {
if (sslGetMatchingCertInArray((SecCertificateRef)CFArrayGetValueAtIndex(certGroup, 0),
ctx->trustedLeafCerts)) {
- serr = noErr;
+ serr = errSecSuccess;
goto errOut;
}
}
case CSSMERR_TP_INVALID_ANCHOR_CERT:
/* root found but we don't trust it */
if(ctx->allowAnyRoot) {
- serr = noErr;
+ serr = errSecSuccess;
sslErrorLog("***Warning: accepting unknown root cert\n");
}
else {
/* no root, not even in implicit SSL roots */
if(ctx->allowAnyRoot) {
sslErrorLog("***Warning: accepting unverified cert chain\n");
- serr = noErr;
+ serr = errSecSuccess;
}
else {
serr = errSSLNoRootCert;
}
#endif
-#pragma mark -
-#pragma mark Diffie-Hellman Support
+// MARK: -
+// MARK: Diffie-Hellman Support
/*
* Generate a Diffie-Hellman key pair. Algorithm parameters always
return ortn;
}
ortn = sslDhGenerateKeyPair(ctx, &sParam, prime->length * 8, publicKey, privateKey);
- SSLFreeBuffer(&sParam, ctx);
+ SSLFreeBuffer(&sParam);
return ortn;
}
CSSM_RETURN crtn;
CSSM_CC_HANDLE ccHandle;
CSSM_DATA labelData = {8, (uint8 *)"tempKey"};
- OSStatus ortn = noErr;
+ OSStatus ortn = errSecSuccess;
CSSM_DATA cParamBlob;
assert(ctx != NULL);
CSSM_CC_HANDLE ccHandle;
CSSM_DATA labelData = {8, (uint8 *)"tempKey"};
CSSM_KEY derivedKey;
- OSStatus ortn = noErr;
+ OSStatus ortn = errSecSuccess;
assert(ctx != NULL);
assert(ctx->cspHand != 0);
return ortn;
}
-#pragma mark -
-#pragma mark *** ECDSA support ***
+// MARK: -
+// MARK: *** ECDSA support ***
/* specify either 32-bit integer or a pointer as an added attribute value */
typedef enum {
CSSM_RETURN crtn;
CSSM_CC_HANDLE ccHandle = 0;
CSSM_DATA labelData = {8, (uint8 *)"ecdsaKey"};
- OSStatus ortn = noErr;
+ OSStatus ortn = errSecSuccess;
CSSM_KEY pubKey;
uint32 keySizeInBits;
assert(ctx != NULL);
assert(ctx->cspHand != 0);
sslFreeKey(ctx->ecdhPrivCspHand, &ctx->ecdhPrivate, NULL);
- SSLFreeBuffer(&ctx->ecdhExchangePublic, ctx);
+ SSLFreeBuffer(&ctx->ecdhExchangePublic);
switch(namedCurve) {
case SSL_Curve_secp256r1:
CSSM_CC_HANDLE ccHandle;
CSSM_DATA labelData = {8, (uint8 *)"tempKey"};
CSSM_KEY derivedKey;
- OSStatus ortn = noErr;
+ OSStatus ortn = errSecSuccess;
CSSM_KEY rawKey;
bool useRefKeys = false;
uint32 keyAttr;
CSSM_DeleteContext(ccHandle);
if(useRefKeys) {
if(pubKeyBits.length) {
- SSLFreeBuffer(&pubKeyBits, ctx);
+ SSLFreeBuffer(&pubKeyBits);
}
if(rawKey.KeyData.Length) {
CSSM_FreeKey(ctx->ecdhPrivCspHand, NULL, &rawKey, CSSM_FALSE);
const SSLCipherSpec *selectedCipherSpec)
{
if(ctx->protocolSide == kSSLClientSide) {
- return noErr;
+ return errSecSuccess;
}
#if SSL_PAC_SERVER_ENABLE
if((ctx->masterSecretCallback != NULL) &&
(ctx->sessionTicket.data != NULL)) {
/* EAP via PAC resumption; we can do it */
- return noErr;
+ return errSecSuccess;
}
#endif /* SSL_PAC_SERVER_ENABLE */
return errSSLInternal;
}
if(requireAlg == CSSM_ALGID_NONE) {
- return noErr;
+ return errSecSuccess;
}
/* private signing key required */
return errSSLBadConfiguration;
}
}
- return noErr;
+ return errSecSuccess;
}
#endif /* USE_CDSA_CRYPTO */