2 * Copyright (c) 2011-2019 Apple Inc. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 // ***************************************************************************
19 // Supporting routines for DNSSEC crypto
20 // ***************************************************************************
22 #include "mDNSEmbeddedAPI.h"
23 #include <CommonCrypto/CommonDigest.h> // For Hash algorithms SHA1 etc.
24 #include <dispatch/dispatch.h> // For Base32/Base64 encoding/decoding
25 #include <dispatch/private.h> // dispatch_data_create_with_transform
26 #include "CryptoAlg.h"
27 #include "CryptoSupport.h"
29 #include "DNSSECSupport.h"
32 #include <Security/SecRSAKey.h> // For RSA_SHA1 etc. verification
34 #include <Security/Security.h>
38 mDNSlocal SecKeyRef
SecKeyCreateRSAPublicKey_OSX(unsigned char *asn1
, int length
);
43 dispatch_data_t encData
;
44 dispatch_data_t encMap
;
45 dispatch_data_t encNULL
;
48 mDNSlocal mStatus
enc_create(AlgContext
*ctx
)
56 ptr
= (encContext
*) mDNSPlatformMemAllocateClear(sizeof(*ptr
));
57 if (!ptr
) return mStatus_NoMemoryErr
;
60 LogMsg("enc_create: Unsupported algorithm %d", ctx
->alg
);
61 return mStatus_BadParamErr
;
65 // The encoded data is not NULL terminated. So, we concatenate a null byte later when we encode and map
67 ptr
->encNULL
= dispatch_data_create("", 1, dispatch_get_global_queue(0, 0), ^{});
70 mDNSPlatformMemFree(ptr
);
71 return mStatus_NoMemoryErr
;
74 return mStatus_NoError
;
77 mDNSlocal mStatus
enc_destroy(AlgContext
*ctx
)
79 encContext
*ptr
= (encContext
*)ctx
->context
;
80 if (ptr
->encData
) dispatch_release(ptr
->encData
);
81 if (ptr
->encMap
) dispatch_release(ptr
->encMap
);
82 if (ptr
->encNULL
) dispatch_release(ptr
->encNULL
);
83 mDNSPlatformMemFree(ptr
);
84 return mStatus_NoError
;
87 mDNSlocal mStatus
enc_add(AlgContext
*ctx
, const void *data
, mDNSu32 len
)
94 encContext
*ptr
= (encContext
*)ctx
->context
;
95 dispatch_data_t src_data
= dispatch_data_create(data
, len
, dispatch_get_global_queue(0, 0), ^{});
98 LogMsg("enc_add: dispatch_data_create src failed");
99 return mStatus_BadParamErr
;
101 dispatch_data_t dest_data
= dispatch_data_create_with_transform(src_data
, DISPATCH_DATA_FORMAT_TYPE_NONE
,
102 (ctx
->alg
== ENC_BASE32
? DISPATCH_DATA_FORMAT_TYPE_BASE32HEX
: DISPATCH_DATA_FORMAT_TYPE_BASE64
));
103 dispatch_release(src_data
);
106 LogMsg("enc_add: dispatch_data_create dst failed");
107 return mStatus_BadParamErr
;
109 ptr
->encData
= dest_data
;
111 return mStatus_NoError
;
114 LogMsg("enc_add: Unsupported algorithm %d", ctx
->alg
);
115 return mStatus_BadParamErr
;
119 mDNSlocal mDNSu8
* enc_encode(AlgContext
*ctx
)
121 const void *result
= NULL
;
128 encContext
*ptr
= (encContext
*)ctx
->context
;
130 dispatch_data_t dest_data
= ptr
->encData
;
131 dispatch_data_t data
= dispatch_data_create_concat(dest_data
, ptr
->encNULL
);
135 LogMsg("enc_encode: cannot concatenate");
139 dispatch_data_t map
= dispatch_data_create_map(data
, &result
, &size
);
142 LogMsg("enc_encode: cannot create map %d", ctx
->alg
);
145 dispatch_release(dest_data
);
149 return (mDNSu8
*)result
;
152 LogMsg("enc_encode: Unsupported algorithm %d", ctx
->alg
);
157 mDNSlocal mStatus
sha_create(AlgContext
*ctx
)
162 case SHA1_DIGEST_TYPE
:
163 ptr
= (mDNSu8
*) mDNSPlatformMemAllocate(sizeof(CC_SHA1_CTX
));
164 if (!ptr
) return mStatus_NoMemoryErr
;
165 CC_SHA1_Init((CC_SHA1_CTX
*)ptr
);
167 case SHA256_DIGEST_TYPE
:
168 ptr
= (mDNSu8
*) mDNSPlatformMemAllocate(sizeof(CC_SHA256_CTX
));
169 if (!ptr
) return mStatus_NoMemoryErr
;
170 CC_SHA256_Init((CC_SHA256_CTX
*)ptr
);
173 LogMsg("sha_create: Unsupported algorithm %d", ctx
->alg
);
174 return mStatus_BadParamErr
;
177 return mStatus_NoError
;
180 mDNSlocal mStatus
sha_destroy(AlgContext
*ctx
)
182 mDNSPlatformMemFree(ctx
->context
);
183 return mStatus_NoError
;
186 mDNSlocal mDNSu32
sha_len(AlgContext
*ctx
)
190 case SHA1_DIGEST_TYPE
:
191 return CC_SHA1_DIGEST_LENGTH
;
192 case SHA256_DIGEST_TYPE
:
193 return CC_SHA256_DIGEST_LENGTH
;
195 LogMsg("sha_len: Unsupported algorithm %d", ctx
->alg
);
196 return mStatus_BadParamErr
;
200 mDNSlocal mStatus
sha_add(AlgContext
*ctx
, const void *data
, mDNSu32 len
)
204 case SHA1_DIGEST_TYPE
:
205 CC_SHA1_Update((CC_SHA1_CTX
*)ctx
->context
, data
, len
);
207 case SHA256_DIGEST_TYPE
:
208 CC_SHA256_Update((CC_SHA256_CTX
*)ctx
->context
, data
, len
);
211 LogMsg("sha_add: Unsupported algorithm %d", ctx
->alg
);
212 return mStatus_BadParamErr
;
214 return mStatus_NoError
;
217 mDNSlocal mStatus
sha_verify(AlgContext
*ctx
, mDNSu8
*key
, mDNSu32 keylen
, mDNSu8
*digestIn
, mDNSu32 dlen
)
219 mDNSu8 digest
[CC_SHA512_DIGEST_LENGTH
];
223 (void)keylen
; //unused
226 case SHA1_DIGEST_TYPE
:
227 digestLen
= CC_SHA1_DIGEST_LENGTH
;
228 CC_SHA1_Final(digest
, (CC_SHA1_CTX
*)ctx
->context
);
230 case SHA256_DIGEST_TYPE
:
231 digestLen
= CC_SHA256_DIGEST_LENGTH
;
232 CC_SHA256_Final(digest
, (CC_SHA256_CTX
*)ctx
->context
);
235 LogMsg("sha_verify: Unsupported algorithm %d", ctx
->alg
);
236 return mStatus_BadParamErr
;
238 if (dlen
!= digestLen
)
240 LogMsg("sha_verify(Alg %d): digest len mismatch len %u, expected %u", ctx
->alg
, (unsigned int)dlen
, (unsigned int)digestLen
);
241 return mStatus_BadParamErr
;
243 if (!memcmp(digest
, digestIn
, digestLen
))
244 return mStatus_NoError
;
246 return mStatus_NoAuth
;
249 mDNSlocal mStatus
sha_final(AlgContext
*ctx
, void *digestOut
, mDNSu32 dlen
)
251 mDNSu8 digest
[CC_SHA512_DIGEST_LENGTH
];
256 case SHA1_DIGEST_TYPE
:
257 digestLen
= CC_SHA1_DIGEST_LENGTH
;
258 CC_SHA1_Final(digest
, (CC_SHA1_CTX
*)ctx
->context
);
260 case SHA256_DIGEST_TYPE
:
261 digestLen
= CC_SHA256_DIGEST_LENGTH
;
262 CC_SHA256_Final(digest
, (CC_SHA256_CTX
*)ctx
->context
);
265 LogMsg("sha_final: Unsupported algorithm %d", ctx
->alg
);
266 return mStatus_BadParamErr
;
268 if (dlen
!= digestLen
)
270 LogMsg("sha_final(Alg %d): digest len mismatch len %u, expected %u", ctx
->alg
, (unsigned int)dlen
, (unsigned int)digestLen
);
271 return mStatus_BadParamErr
;
273 memcpy(digestOut
, digest
, digestLen
);
274 return mStatus_NoError
;
277 mDNSlocal mStatus
rsa_sha_create(AlgContext
*ctx
)
282 case CRYPTO_RSA_NSEC3_SHA1
:
283 case CRYPTO_RSA_SHA1
:
284 ptr
= (mDNSu8
*) mDNSPlatformMemAllocate(sizeof(CC_SHA1_CTX
));
285 if (!ptr
) return mStatus_NoMemoryErr
;
286 CC_SHA1_Init((CC_SHA1_CTX
*)ptr
);
288 case CRYPTO_RSA_SHA256
:
289 ptr
= (mDNSu8
*) mDNSPlatformMemAllocate(sizeof(CC_SHA256_CTX
));
290 if (!ptr
) return mStatus_NoMemoryErr
;
291 CC_SHA256_Init((CC_SHA256_CTX
*)ptr
);
293 case CRYPTO_RSA_SHA512
:
294 ptr
= (mDNSu8
*) mDNSPlatformMemAllocate(sizeof(CC_SHA512_CTX
));
295 if (!ptr
) return mStatus_NoMemoryErr
;
296 CC_SHA512_Init((CC_SHA512_CTX
*)ptr
);
299 LogMsg("rsa_sha_create: Unsupported algorithm %d", ctx
->alg
);
300 return mStatus_BadParamErr
;
303 return mStatus_NoError
;
306 mDNSlocal mStatus
rsa_sha_destroy(AlgContext
*ctx
)
308 mDNSPlatformMemFree(ctx
->context
);
309 return mStatus_NoError
;
312 mDNSlocal mDNSu32
rsa_sha_len(AlgContext
*ctx
)
316 case CRYPTO_RSA_NSEC3_SHA1
:
317 case CRYPTO_RSA_SHA1
:
318 return CC_SHA1_DIGEST_LENGTH
;
319 case CRYPTO_RSA_SHA256
:
320 return CC_SHA256_DIGEST_LENGTH
;
321 case CRYPTO_RSA_SHA512
:
322 return CC_SHA512_DIGEST_LENGTH
;
324 LogMsg("rsa_sha_len: Unsupported algorithm %d", ctx
->alg
);
325 return mStatus_BadParamErr
;
329 mDNSlocal mStatus
rsa_sha_add(AlgContext
*ctx
, const void *data
, mDNSu32 len
)
333 case CRYPTO_RSA_NSEC3_SHA1
:
334 case CRYPTO_RSA_SHA1
:
335 CC_SHA1_Update((CC_SHA1_CTX
*)ctx
->context
, data
, len
);
337 case CRYPTO_RSA_SHA256
:
338 CC_SHA256_Update((CC_SHA256_CTX
*)ctx
->context
, data
, len
);
340 case CRYPTO_RSA_SHA512
:
341 CC_SHA512_Update((CC_SHA512_CTX
*)ctx
->context
, data
, len
);
344 LogMsg("rsa_sha_add: Unsupported algorithm %d", ctx
->alg
);
345 return mStatus_BadParamErr
;
347 return mStatus_NoError
;
350 mDNSlocal SecKeyRef
rfc3110_import(const mDNSu8
*data
, const mDNSu32 len
)
352 static const int max_modulus_bytes
= 512; // Modulus is limited to 4096 bits (512 octets) in length.
353 static const int max_exp_bytes
= 512; // Exponent is limited to 4096 bits (512 octets) in length.
354 static const int asn1_type_bytes
= 3; // Since there is an ASN1 SEQ and two INTs.
355 static const int asn1_max_len_bytes
= 3 * 3; // Capped at 3 due to max payload size.
356 unsigned char asn1
[max_modulus_bytes
+ 1 + max_exp_bytes
+ asn1_type_bytes
+ asn1_max_len_bytes
]; // +1 is for leading 0 for non negative asn1 number
357 const mDNSu8
*modulus
;
358 unsigned int modulus_length
;
359 const mDNSu8
*exponent
;
360 unsigned int exp_length
;
361 unsigned int num_length_bytes
;
363 mDNSu32 asn1_length
= 0;
369 // we have to have at least 1 byte for the length
373 // Parse Modulus and Exponent
375 // If the first byte is zero, then the exponent length is in the three-byte format, otherwise the length is in the first byte.
380 exp_length
= (data
[1] << 8) | data
[2];
381 num_length_bytes
= 3;
385 exp_length
= data
[0];
386 num_length_bytes
= 1;
389 // RFC3110 limits the exponent length to 4096 bits (512 octets).
390 if (exp_length
> 512)
393 // We have to have at least len bytes + size of exponent.
394 if (len
< (num_length_bytes
+ exp_length
))
397 // The modulus is the remaining space.
398 modulus_length
= len
- (num_length_bytes
+ exp_length
);
400 // RFC3110 limits the modulus length to 4096 bits (512 octets).
401 if (modulus_length
> 512)
404 if (modulus_length
< 1)
407 // add 1 to modulus length for pre-ceding 0 t make ASN1 value non-negative
410 exponent
= &data
[num_length_bytes
];
411 modulus
= &data
[num_length_bytes
+ exp_length
];
413 // 2 bytes for commands since first doesn't count
414 // 2 bytes for min 1 byte length field
415 asn1_length
= modulus_length
+ exp_length
+ 2 + 2;
417 // Account for modulus length causing INT length field to grow.
418 if (modulus_length
>= 128)
420 if (modulus_length
> 255)
426 // Account for exponent length causing INT length field to grow.
427 if (exp_length
>= 128)
429 if (exp_length
> 255)
435 // Construct ASN1 formatted public key
436 // Write ASN1 SEQ byte
437 asn1
[index
++] = 0x30;
439 // Write ASN1 length for SEQ
440 if (asn1_length
< 128)
442 asn1
[index
++] = asn1_length
& 0xFF;
446 asn1
[index
++] = (0x80 | ((asn1_length
> 255) ? 2 : 1));
447 if (asn1_length
> 255)
448 asn1
[index
++] = (asn1_length
& 0xFF00) >> 8;
449 asn1
[index
++] = asn1_length
& 0xFF;
452 // Write ASN1 INT for modulus
453 asn1
[index
++] = 0x02;
454 // Write ASN1 length for INT
455 if (modulus_length
< 128)
457 asn1
[index
++] = modulus_length
& 0xFF;
461 asn1
[index
++] = 0x80 | ((modulus_length
> 255) ? 2 : 1);
462 if (modulus_length
> 255)
463 asn1
[index
++] = (modulus_length
& 0xFF00) >> 8;
464 asn1
[index
++] = modulus_length
& 0xFF;
467 // Write preceding 0 so our integer isn't negative
468 asn1
[index
++] = 0x00;
469 // Write actual modulus (-1 for preceding 0)
470 memcpy(&asn1
[index
], modulus
, modulus_length
- 1);
471 index
+= (modulus_length
- 1);
473 // Write ASN1 INT for exponent
474 asn1
[index
++] = 0x02;
475 // Write ASN1 length for INT
476 if (exp_length
< 128)
478 asn1
[index
++] = exp_length
& 0xFF;
482 asn1
[index
++] = 0x80 | ((exp_length
> 255) ? 2 : 1);
483 if (exp_length
> 255)
484 asn1
[index
++] = (exp_length
& 0xFF00) >> 8;
485 asn1
[index
++] = exp_length
& 0xFF;
487 // Write exponent bytes
488 memcpy(&asn1
[index
], exponent
, exp_length
);
492 // index contains bytes written, use it for length
493 return (SecKeyCreateRSAPublicKey(NULL
, asn1
, index
, kSecKeyEncodingPkcs1
));
495 return (SecKeyCreateRSAPublicKey_OSX(asn1
, index
));
500 mDNSlocal mStatus
rsa_sha_verify(AlgContext
*ctx
, mDNSu8
*key
, mDNSu32 keylen
, mDNSu8
*signature
, mDNSu32 siglen
)
504 mDNSu8 digest
[CC_SHA512_DIGEST_LENGTH
];
510 case CRYPTO_RSA_NSEC3_SHA1
:
511 case CRYPTO_RSA_SHA1
:
512 cryptoAlg
= kSecPaddingPKCS1SHA1
;
513 digestlen
= CC_SHA1_DIGEST_LENGTH
;
514 CC_SHA1_Final(digest
, (CC_SHA1_CTX
*)ctx
->context
);
516 case CRYPTO_RSA_SHA256
:
517 cryptoAlg
= kSecPaddingPKCS1SHA256
;
518 digestlen
= CC_SHA256_DIGEST_LENGTH
;
519 CC_SHA256_Final(digest
, (CC_SHA256_CTX
*)ctx
->context
);
521 case CRYPTO_RSA_SHA512
:
522 cryptoAlg
= kSecPaddingPKCS1SHA512
;
523 digestlen
= CC_SHA512_DIGEST_LENGTH
;
524 CC_SHA512_Final(digest
, (CC_SHA512_CTX
*)ctx
->context
);
527 LogMsg("rsa_sha_verify: Unsupported algorithm %d", ctx
->alg
);
528 return mStatus_BadParamErr
;
531 keyref
= rfc3110_import(key
, keylen
);
534 LogMsg("rsa_sha_verify: Error decoding rfc3110 key data");
535 return mStatus_NoMemoryErr
;
537 result
= SecKeyRawVerify(keyref
, cryptoAlg
, digest
, digestlen
, signature
, siglen
);
541 LogMsg("rsa_sha_verify: Failed for alg %d", ctx
->alg
);
542 return mStatus_BadParamErr
;
546 LogInfo("rsa_sha_verify: Passed for alg %d", ctx
->alg
);
547 return mStatus_NoError
;
550 #else // TARGET_OS_IPHONE
552 mDNSlocal SecKeyRef
SecKeyCreateRSAPublicKey_OSX(unsigned char *asn1
, int length
)
554 SecKeyRef result
= NULL
;
556 SecExternalFormat extFormat
= kSecFormatBSAFE
;
557 SecExternalItemType itemType
= kSecItemTypePublicKey
;
558 CFArrayRef outArray
= NULL
;
560 CFDataRef keyData
= CFDataCreate(NULL
, asn1
, length
);
564 OSStatus err
= SecItemImport(keyData
, NULL
, &extFormat
, &itemType
, 0, NULL
, NULL
, &outArray
);
567 if (noErr
!= err
|| outArray
== NULL
)
574 result
= (SecKeyRef
)CFArrayGetValueAtIndex(outArray
, 0);
586 mDNSlocal Boolean
VerifyData(SecKeyRef key
, CFStringRef digestStr
, mDNSu8
*digest
, int dlen
, int digestlenAttr
, mDNSu8
*sig
, int siglen
, CFStringRef digest_type
)
591 CFDataRef signature
= CFDataCreate(NULL
, sig
, siglen
);
595 SecTransformRef verifyXForm
= SecVerifyTransformCreate(key
, signature
, &error
);
596 CFRelease(signature
);
597 if (verifyXForm
== NULL
)
602 // tell the transform what type of data it is geting
603 if (!SecTransformSetAttribute(verifyXForm
, kSecInputIsAttributeName
, digest_type
, &error
))
605 LogMsg("VerifyData: SecTransformSetAttribute digest_type");
609 if (!SecTransformSetAttribute(verifyXForm
, kSecDigestTypeAttribute
, digestStr
, &error
))
611 LogMsg("VerifyData: SecTransformSetAttribute digestStr");
615 CFNumberRef digestLengthRef
= CFNumberCreate(kCFAllocatorDefault
, kCFNumberCFIndexType
, &digestlenAttr
);
616 if (digestLengthRef
== NULL
)
618 LogMsg("VerifyData: CFNumberCreate failed");
622 ret
= SecTransformSetAttribute(verifyXForm
, kSecDigestLengthAttribute
, digestLengthRef
, &error
);
623 CFRelease(digestLengthRef
);
626 LogMsg("VerifyData: SecTransformSetAttribute digestLengthRef");
630 CFDataRef dataToSign
= CFDataCreate(NULL
, digest
, dlen
);
631 if (dataToSign
== NULL
)
633 LogMsg("VerifyData: CFDataCreate failed");
637 ret
= SecTransformSetAttribute(verifyXForm
, kSecTransformInputAttributeName
, dataToSign
, &error
);
638 CFRelease(dataToSign
);
641 LogMsg("VerifyData: SecTransformSetAttribute TransformAttributeName");
645 CFBooleanRef boolRef
= SecTransformExecute(verifyXForm
, &error
);
646 ret
= (boolRef
!= NULL
) ? CFBooleanGetValue(boolRef
) : false;
647 if (boolRef
!= NULL
) CFRelease(boolRef
);
648 CFRelease(verifyXForm
);
652 CFStringRef errStr
= CFErrorCopyDescription(error
);
657 if (!CFStringGetCString(errStr
, errorbuf
, sizeof(errorbuf
), kCFStringEncodingUTF8
))
659 LogMsg("VerifyData: CFStringGetCString failed");
663 LogMsg("VerifyData: SecTransformExecute failed with %s", errorbuf
);
668 CFRelease(verifyXForm
);
672 mDNSlocal mStatus
rsa_sha_verify(AlgContext
*ctx
, mDNSu8
*key
, mDNSu32 keylen
, mDNSu8
*signature
, mDNSu32 siglen
)
675 mDNSu8 digest
[CC_SHA512_DIGEST_LENGTH
];
678 CFStringRef digestStr
;
683 case CRYPTO_RSA_NSEC3_SHA1
:
684 case CRYPTO_RSA_SHA1
:
685 digestStr
= kSecDigestSHA1
;
686 digestlen
= CC_SHA1_DIGEST_LENGTH
;
688 CC_SHA1_Final(digest
, (CC_SHA1_CTX
*)ctx
->context
);
690 case CRYPTO_RSA_SHA256
:
691 digestStr
= kSecDigestSHA2
;
692 digestlen
= CC_SHA256_DIGEST_LENGTH
;
694 CC_SHA256_Final(digest
, (CC_SHA256_CTX
*)ctx
->context
);
696 case CRYPTO_RSA_SHA512
:
697 digestStr
= kSecDigestSHA2
;
698 digestlen
= CC_SHA512_DIGEST_LENGTH
;
700 CC_SHA512_Final(digest
, (CC_SHA512_CTX
*)ctx
->context
);
703 LogMsg("rsa_sha_verify: Unsupported algorithm %d", ctx
->alg
);
704 return mStatus_BadParamErr
;
707 keyref
= rfc3110_import(key
, keylen
);
710 LogMsg("rsa_sha_verify: Error decoding rfc3110 key data");
711 return mStatus_NoMemoryErr
;
713 ret
= VerifyData(keyref
, digestStr
, digest
, digestlen
, digestlenAttr
, signature
, siglen
, kSecInputIsDigest
);
717 LogMsg("rsa_sha_verify: Failed for alg %d", ctx
->alg
);
718 return mStatus_BadParamErr
;
722 LogInfo("rsa_sha_verify: Passed for alg %d", ctx
->alg
);
723 return mStatus_NoError
;
726 #endif // TARGET_OS_IPHONE
728 AlgFuncs sha_funcs
= {sha_create
, sha_destroy
, sha_len
, sha_add
, sha_verify
, mDNSNULL
, sha_final
};
729 AlgFuncs rsa_sha_funcs
= {rsa_sha_create
, rsa_sha_destroy
, rsa_sha_len
, rsa_sha_add
, rsa_sha_verify
, mDNSNULL
, mDNSNULL
};
730 AlgFuncs enc_funcs
= {enc_create
, enc_destroy
, mDNSNULL
, enc_add
, mDNSNULL
, enc_encode
, mDNSNULL
};
732 #ifndef DNSSEC_DISABLED
734 mDNSexport mStatus
DNSSECCryptoInit(mDNS
*const m
)
738 result
= DigestAlgInit(SHA1_DIGEST_TYPE
, &sha_funcs
);
739 if (result
!= mStatus_NoError
)
741 result
= DigestAlgInit(SHA256_DIGEST_TYPE
, &sha_funcs
);
742 if (result
!= mStatus_NoError
)
744 result
= CryptoAlgInit(CRYPTO_RSA_SHA1
, &rsa_sha_funcs
);
745 if (result
!= mStatus_NoError
)
747 result
= CryptoAlgInit(CRYPTO_RSA_NSEC3_SHA1
, &rsa_sha_funcs
);
748 if (result
!= mStatus_NoError
)
750 result
= CryptoAlgInit(CRYPTO_RSA_SHA256
, &rsa_sha_funcs
);
751 if (result
!= mStatus_NoError
)
753 result
= CryptoAlgInit(CRYPTO_RSA_SHA512
, &rsa_sha_funcs
);
754 if (result
!= mStatus_NoError
)
756 result
= EncAlgInit(ENC_BASE32
, &enc_funcs
);
757 if (result
!= mStatus_NoError
)
759 result
= EncAlgInit(ENC_BASE64
, &enc_funcs
);
760 if (result
!= mStatus_NoError
)
763 result
= DNSSECPlatformInit(m
);
768 #else // !DNSSEC_DISABLED
770 mDNSexport mStatus
DNSSECCryptoInit(mDNS
*const m
)
774 return mStatus_NoError
;
777 #endif // !DNSSEC_DISABLED