5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome/* -*- Mode: C; tab-width: 4 -*-
cda73f64f20b8a0afc4909f5ea1f055ec7913856Toomas Soome * Copyright (c) 2011-2012 Apple Inc. All rights reserved.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Licensed under the Apache License, Version 2.0 (the "License");
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * you may not use this file except in compliance with the License.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * You may obtain a copy of the License at
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * Unless required by applicable law or agreed to in writing, software
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * distributed under the License is distributed on an "AS IS" BASIS,
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * See the License for the specific language governing permissions and
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome * limitations under the License.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome// ***************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome// Interface to DNSSEC cryptographic algorithms. The crypto support itself is
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome// provided by the platform and the functions in this file just provide an
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome// interface to access them in a more generic way.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome// ***************************************************************************
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomemDNSexport mStatus DigestAlgInit(mDNSu8 digestType, AlgFuncs *func)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome LogMsg("DigestAlgInit: digestType %d exceeds bounds", digestType);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // As digestTypes may not be consecutive, check for specific digest types
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // that we support
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome LogMsg("DigestAlgInit: digestType %d not supported", digestType);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomemDNSexport mStatus CryptoAlgInit(mDNSu8 alg, AlgFuncs *func)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome LogMsg("CryptoAlgInit: alg %d exceeds bounds", alg);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // As algs may not be consecutive, check for specific algorithms
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // that we support
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome if (alg != CRYPTO_RSA_SHA1 && alg != CRYPTO_RSA_SHA256 && alg != CRYPTO_RSA_SHA512 &&
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome alg != CRYPTO_DSA_NSEC3_SHA1 && alg != CRYPTO_RSA_NSEC3_SHA1)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome LogMsg("CryptoAlgInit: alg %d not supported", alg);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomemDNSexport mStatus EncAlgInit(mDNSu8 alg, AlgFuncs *func)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome LogMsg("EncAlgInit: alg %d exceeds bounds", alg);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // As algs may not be consecutive, check for specific algorithms
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // that we support
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome LogMsg("EncAlgInit: alg %d not supported", alg);
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomemDNSexport AlgContext *AlgCreate(AlgType type, mDNSu8 alg)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // If there is no support from the platform, this case can happen.
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome ctx = mDNSPlatformMemAllocate(sizeof(AlgContext));
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // Create expects ctx->alg to be initialized
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // This should never happen as AlgCreate would have failed
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomemDNSexport mStatus AlgAdd(AlgContext *ctx, const void *data, mDNSu32 len)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // This should never happen as AlgCreate would have failed
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomemDNSexport mStatus AlgVerify(AlgContext *ctx, mDNSu8 *key, mDNSu32 keylen, mDNSu8 *signature, mDNSu32 siglen)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // This should never happen as AlgCreate would have failed
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome return (func->Verify(ctx, key, keylen, signature, siglen));
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // This should never happen as AlgCreate would have failed
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas SoomemDNSexport mStatus AlgFinal(AlgContext *ctx, void *data, mDNSu32 len)
5ffb0c9b03b5149ff4f5821a62be4a52408ada2aToomas Soome // This should never happen as AlgCreate would have failed