]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSCore/CryptoAlg.h
mDNSResponder-379.27.tar.gz
[apple/mdnsresponder.git] / mDNSCore / CryptoAlg.h
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2011 Apple Computer, Inc. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 #ifndef __CRYPTO_ALG_H
18 #define __CRYPTO_ALG_H
19
20 typedef enum
21 {
22 CRYPTO_ALG,
23 DIGEST_ALG,
24 ENC_ALG,
25 } AlgType;
26
27 typedef struct
28 {
29 void *context;
30 AlgType type;
31 mDNSu8 alg;
32 } AlgContext;
33
34 typedef struct
35 {
36 mStatus (*Create)(AlgContext *ctx);
37 mStatus (*Destroy)(AlgContext *ctx);
38 mDNSu32 (*Length)(AlgContext *ctx);
39 mStatus (*Add)(AlgContext *ctx, void *data, mDNSu32 len);
40 // Verify the ctx using the key and compare it against signature/siglen
41 mStatus (*Verify)(AlgContext *ctx, mDNSu8 *key, mDNSu32 keylen, mDNSu8 *signature, mDNSu32 siglen);
42 // Encode the data and return the encoded data
43 mDNSu8* (*Encode)(AlgContext *ctx);
44 } AlgFuncs;
45
46 mDNSexport mStatus DigestAlgInit(mDNSu8 digestType, AlgFuncs *func);
47 mDNSexport mStatus CryptoAlgInit(mDNSu8 algType, AlgFuncs *func);
48 mDNSexport mStatus EncAlgInit(mDNSu8 algType, AlgFuncs *func);
49
50
51 extern AlgContext *AlgCreate(AlgType type, mDNSu8 alg);
52 extern mStatus AlgDestroy(AlgContext *ctx);
53 extern mDNSu32 AlgLength(AlgContext *ctx);
54 extern mStatus AlgAdd(AlgContext *ctx, void *data, mDNSu32 len);
55 extern mStatus AlgVerify(AlgContext *ctx, mDNSu8 *key, mDNSu32 keylen, mDNSu8 *signature, mDNSu32 siglen);
56 extern mDNSu8* AlgEncode(AlgContext *ctx);
57
58 #endif // __CRYPTO_ALG_H