/* -*- Mode: C; tab-width: 4 -*-
*
* Copyright (c) 2011-2012 Apple Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ***************************************************************************
// CryptoAlg.c:
// Interface to DNSSEC cryptographic algorithms. The crypto support itself is
// provided by the platform and the functions in this file just provide an
// interface to access them in a more generic way.
// ***************************************************************************
#include "mDNSEmbeddedAPI.h"
#include "CryptoAlg.h"
{
if (digestType >= DIGEST_TYPE_MAX)
{
return mStatus_BadParamErr;
}
// As digestTypes may not be consecutive, check for specific digest types
// that we support
if (digestType != SHA1_DIGEST_TYPE &&
{
return mStatus_BadParamErr;
}
return mStatus_NoError;
}
{
if (alg >= CRYPTO_ALG_MAX)
{
return mStatus_BadParamErr;
}
// As algs may not be consecutive, check for specific algorithms
// that we support
{
return mStatus_BadParamErr;
}
return mStatus_NoError;
}
{
if (alg >= ENC_ALG_MAX)
{
return mStatus_BadParamErr;
}
// As algs may not be consecutive, check for specific algorithms
// that we support
{
return mStatus_BadParamErr;
}
return mStatus_NoError;
}
{
if (type == CRYPTO_ALG)
{
}
else if (type == DIGEST_ALG)
{
}
{
}
if (!func)
{
// If there is no support from the platform, this case can happen.
LogInfo("AlgCreate: func is NULL");
return mDNSNULL;
}
{
// Create expects ctx->alg to be initialized
if (err == mStatus_NoError)
{
return ctx;
}
}
return mDNSNULL;
}
{
if (!func)
{
LogMsg("AlgDestroy: ERROR!! func is NULL");
return mStatus_BadParamErr;
}
return mStatus_NoError;
}
{
// This should never happen as AlgCreate would have failed
if (!func)
{
LogMsg("AlgLength: ERROR!! func is NULL");
return 0;
}
else
return 0;
}
{
// This should never happen as AlgCreate would have failed
if (!func)
{
LogMsg("AlgAdd: ERROR!! func is NULL");
return mStatus_BadParamErr;
}
else
return mStatus_BadParamErr;
}
mDNSexport mStatus AlgVerify(AlgContext *ctx, mDNSu8 *key, mDNSu32 keylen, mDNSu8 *signature, mDNSu32 siglen)
{
// This should never happen as AlgCreate would have failed
if (!func)
{
LogMsg("AlgVerify: ERROR!! func is NULL");
return mStatus_BadParamErr;
}
else
return mStatus_BadParamErr;
}
{
// This should never happen as AlgCreate would have failed
if (!func)
{
LogMsg("AlgEncode: ERROR!! func is NULL");
return mDNSNULL;
}
else
return mDNSNULL;
}
{
// This should never happen as AlgCreate would have failed
if (!func)
{
LogMsg("AlgEncode: ERROR!! func is NULL");
return mDNSNULL;
}
else
return mStatus_BadParamErr;
}