1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2011-2013 Apple Inc. All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 // ***************************************************************************
20 // Supporting routines for DNSSEC crypto
21 // ***************************************************************************
23 #include "mDNSEmbeddedAPI.h"
24 #include <CommonCrypto/CommonDigest.h> // For Hash algorithms SHA1 etc.
25 #include <dispatch/dispatch.h> // For Base32/Base64 encoding/decoding
26 #include <dispatch/private.h> // dispatch_data_create_with_transform
27 #include "CryptoAlg.h"
28 #include "CryptoSupport.h"
30 #include "DNSSECSupport.h"
33 #include "SecRSAKey.h" // For RSA_SHA1 etc. verification
35 #include <Security/Security.h>
39 mDNSlocal SecKeyRef
SecKeyCreateRSAPublicKey_OSX(unsigned char *asn1
, int length
);
44 dispatch_data_t encData
;
45 dispatch_data_t encMap
;
46 dispatch_data_t encNULL
;
49 mDNSlocal mStatus
enc_create(AlgContext
*ctx
)
57 ptr
= (encContext
*)mDNSPlatformMemAllocate(sizeof(encContext
));
58 if (!ptr
) return mStatus_NoMemoryErr
;
61 LogMsg("enc_create: Unsupported algorithm %d", ctx
->alg
);
62 return mStatus_BadParamErr
;
66 // The encoded data is not NULL terminated. So, we concatenate a null byte later when we encode and map
68 ptr
->encNULL
= dispatch_data_create("", 1, dispatch_get_global_queue(0, 0), ^{});
71 mDNSPlatformMemFree(ptr
);
72 return mStatus_NoMemoryErr
;
75 return mStatus_NoError
;
78 mDNSlocal mStatus
enc_destroy(AlgContext
*ctx
)
80 encContext
*ptr
= (encContext
*)ctx
->context
;
81 if (ptr
->encData
) dispatch_release(ptr
->encData
);
82 if (ptr
->encMap
) dispatch_release(ptr
->encMap
);
83 if (ptr
->encNULL
) dispatch_release(ptr
->encNULL
);
84 mDNSPlatformMemFree(ptr
);
85 return mStatus_NoError
;
88 mDNSlocal mStatus
enc_add(AlgContext
*ctx
, const void *data
, mDNSu32 len
)
95 encContext
*ptr
= (encContext
*)ctx
->context
;
96 dispatch_data_t src_data
= dispatch_data_create(data
, len
, dispatch_get_global_queue(0, 0), ^{});
99 LogMsg("enc_add: dispatch_data_create src failed");
100 return mStatus_BadParamErr
;
102 dispatch_data_t dest_data
= dispatch_data_create_with_transform(src_data
, DISPATCH_DATA_FORMAT_TYPE_NONE
,
103 (ctx
->alg
== ENC_BASE32
? DISPATCH_DATA_FORMAT_TYPE_BASE32HEX
: DISPATCH_DATA_FORMAT_TYPE_BASE64
));
104 dispatch_release(src_data
);
107 LogMsg("enc_add: dispatch_data_create dst failed");
108 return mStatus_BadParamErr
;
110 ptr
->encData
= dest_data
;
112 return mStatus_NoError
;
115 LogMsg("enc_add: Unsupported algorithm %d", ctx
->alg
);
116 return mStatus_BadParamErr
;
120 mDNSlocal mDNSu8
* enc_encode(AlgContext
*ctx
)
122 const void *result
= NULL
;
129 encContext
*ptr
= (encContext
*)ctx
->context
;
131 dispatch_data_t dest_data
= ptr
->encData
;
132 dispatch_data_t data
= dispatch_data_create_concat(dest_data
, ptr
->encNULL
);
136 LogMsg("enc_encode: cannot concatenate");
140 dispatch_data_t map
= dispatch_data_create_map(data
, &result
, &size
);
143 LogMsg("enc_encode: cannot create map %d", ctx
->alg
);
146 dispatch_release(dest_data
);
150 return (mDNSu8
*)result
;
153 LogMsg("enc_encode: Unsupported algorithm %d", ctx
->alg
);
158 mDNSlocal mStatus
sha_create(AlgContext
*ctx
)
163 case SHA1_DIGEST_TYPE
:
164 ptr
= mDNSPlatformMemAllocate(sizeof(CC_SHA1_CTX
));
165 if (!ptr
) return mStatus_NoMemoryErr
;
166 CC_SHA1_Init((CC_SHA1_CTX
*)ptr
);
168 case SHA256_DIGEST_TYPE
:
169 ptr
= mDNSPlatformMemAllocate(sizeof(CC_SHA256_CTX
));
170 if (!ptr
) return mStatus_NoMemoryErr
;
171 CC_SHA256_Init((CC_SHA256_CTX
*)ptr
);
174 LogMsg("sha_create: Unsupported algorithm %d", ctx
->alg
);
175 return mStatus_BadParamErr
;
178 return mStatus_NoError
;
181 mDNSlocal mStatus
sha_destroy(AlgContext
*ctx
)
183 mDNSPlatformMemFree(ctx
->context
);
184 return mStatus_NoError
;
187 mDNSlocal mDNSu32
sha_len(AlgContext
*ctx
)
191 case SHA1_DIGEST_TYPE
:
192 return CC_SHA1_DIGEST_LENGTH
;
193 case SHA256_DIGEST_TYPE
:
194 return CC_SHA256_DIGEST_LENGTH
;
196 LogMsg("sha_len: Unsupported algorithm %d", ctx
->alg
);
197 return mStatus_BadParamErr
;
201 mDNSlocal mStatus
sha_add(AlgContext
*ctx
, const void *data
, mDNSu32 len
)
205 case SHA1_DIGEST_TYPE
:
206 CC_SHA1_Update((CC_SHA1_CTX
*)ctx
->context
, data
, len
);
208 case SHA256_DIGEST_TYPE
:
209 CC_SHA256_Update((CC_SHA256_CTX
*)ctx
->context
, data
, len
);
212 LogMsg("sha_add: Unsupported algorithm %d", ctx
->alg
);
213 return mStatus_BadParamErr
;
215 return mStatus_NoError
;
218 mDNSlocal mStatus
sha_verify(AlgContext
*ctx
, mDNSu8
*key
, mDNSu32 keylen
, mDNSu8
*digestIn
, mDNSu32 dlen
)
220 mDNSu8 digest
[CC_SHA512_DIGEST_LENGTH
];
224 (void)keylen
; //unused
227 case SHA1_DIGEST_TYPE
:
228 digestLen
= CC_SHA1_DIGEST_LENGTH
;
229 CC_SHA1_Final(digest
, (CC_SHA1_CTX
*)ctx
->context
);
231 case SHA256_DIGEST_TYPE
:
232 digestLen
= CC_SHA256_DIGEST_LENGTH
;
233 CC_SHA256_Final(digest
, (CC_SHA256_CTX
*)ctx
->context
);
236 LogMsg("sha_verify: Unsupported algorithm %d", ctx
->alg
);
237 return mStatus_BadParamErr
;
239 if (dlen
!= digestLen
)
241 LogMsg("sha_verify(Alg %d): digest len mismatch len %u, expected %u", ctx
->alg
, (unsigned int)dlen
, (unsigned int)digestLen
);
242 return mStatus_BadParamErr
;
244 if (!memcmp(digest
, digestIn
, digestLen
))
245 return mStatus_NoError
;
247 return mStatus_NoAuth
;
250 mDNSlocal mStatus
sha_final(AlgContext
*ctx
, void *digestOut
, mDNSu32 dlen
)
252 mDNSu8 digest
[CC_SHA512_DIGEST_LENGTH
];
257 case SHA1_DIGEST_TYPE
:
258 digestLen
= CC_SHA1_DIGEST_LENGTH
;
259 CC_SHA1_Final(digest
, (CC_SHA1_CTX
*)ctx
->context
);
261 case SHA256_DIGEST_TYPE
:
262 digestLen
= CC_SHA256_DIGEST_LENGTH
;
263 CC_SHA256_Final(digest
, (CC_SHA256_CTX
*)ctx
->context
);
266 LogMsg("sha_final: Unsupported algorithm %d", ctx
->alg
);
267 return mStatus_BadParamErr
;
269 if (dlen
!= digestLen
)
271 LogMsg("sha_final(Alg %d): digest len mismatch len %u, expected %u", ctx
->alg
, (unsigned int)dlen
, (unsigned int)digestLen
);
272 return mStatus_BadParamErr
;
274 memcpy(digestOut
, digest
, digestLen
);
275 return mStatus_NoError
;
278 mDNSlocal mStatus
rsa_sha_create(AlgContext
*ctx
)
283 case CRYPTO_RSA_NSEC3_SHA1
:
284 case CRYPTO_RSA_SHA1
:
285 ptr
= mDNSPlatformMemAllocate(sizeof(CC_SHA1_CTX
));
286 if (!ptr
) return mStatus_NoMemoryErr
;
287 CC_SHA1_Init((CC_SHA1_CTX
*)ptr
);
289 case CRYPTO_RSA_SHA256
:
290 ptr
= mDNSPlatformMemAllocate(sizeof(CC_SHA256_CTX
));
291 if (!ptr
) return mStatus_NoMemoryErr
;
292 CC_SHA256_Init((CC_SHA256_CTX
*)ptr
);
294 case CRYPTO_RSA_SHA512
:
295 ptr
= mDNSPlatformMemAllocate(sizeof(CC_SHA512_CTX
));
296 if (!ptr
) return mStatus_NoMemoryErr
;
297 CC_SHA512_Init((CC_SHA512_CTX
*)ptr
);
300 LogMsg("rsa_sha_create: Unsupported algorithm %d", ctx
->alg
);
301 return mStatus_BadParamErr
;
304 return mStatus_NoError
;
307 mDNSlocal mStatus
rsa_sha_destroy(AlgContext
*ctx
)
309 mDNSPlatformMemFree(ctx
->context
);
310 return mStatus_NoError
;
313 mDNSlocal mDNSu32
rsa_sha_len(AlgContext
*ctx
)
317 case CRYPTO_RSA_NSEC3_SHA1
:
318 case CRYPTO_RSA_SHA1
:
319 return CC_SHA1_DIGEST_LENGTH
;
320 case CRYPTO_RSA_SHA256
:
321 return CC_SHA256_DIGEST_LENGTH
;
322 case CRYPTO_RSA_SHA512
:
323 return CC_SHA512_DIGEST_LENGTH
;
325 LogMsg("rsa_sha_len: Unsupported algorithm %d", ctx
->alg
);
326 return mStatus_BadParamErr
;
330 mDNSlocal mStatus
rsa_sha_add(AlgContext
*ctx
, const void *data
, mDNSu32 len
)
334 case CRYPTO_RSA_NSEC3_SHA1
:
335 case CRYPTO_RSA_SHA1
:
336 CC_SHA1_Update((CC_SHA1_CTX
*)ctx
->context
, data
, len
);
338 case CRYPTO_RSA_SHA256
:
339 CC_SHA256_Update((CC_SHA256_CTX
*)ctx
->context
, data
, len
);
341 case CRYPTO_RSA_SHA512
:
342 CC_SHA512_Update((CC_SHA512_CTX
*)ctx
->context
, data
, len
);
345 LogMsg("rsa_sha_add: Unsupported algorithm %d", ctx
->alg
);
346 return mStatus_BadParamErr
;
348 return mStatus_NoError
;
351 mDNSlocal SecKeyRef
rfc3110_import(const mDNSu8
*data
, const mDNSu32 len
)
353 static const int max_modulus_bytes
= 512; // Modulus is limited to 4096 bits (512 octets) in length.
354 static const int max_exp_bytes
= 512; // Exponent is limited to 4096 bits (512 octets) in length.
355 static const int asn1_type_bytes
= 3; // Since there is an ASN1 SEQ and two INTs.
356 static const int asn1_max_len_bytes
= 3 * 3; // Capped at 3 due to max payload size.
357 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
358 const mDNSu8
*modulus
;
359 unsigned int modulus_length
;
360 const mDNSu8
*exponent
;
361 unsigned int exp_length
;
362 unsigned int num_length_bytes
;
364 mDNSu32 asn1_length
= 0;
370 // we have to have at least 1 byte for the length
374 // Parse Modulus and Exponent
376 // If the first byte is zero, then the exponent length is in the three-byte format, otherwise the length is in the first byte.
381 exp_length
= (data
[1] << 8) | data
[2];
382 num_length_bytes
= 3;
386 exp_length
= data
[0];
387 num_length_bytes
= 1;
390 // RFC3110 limits the exponent length to 4096 bits (512 octets).
391 if (exp_length
> 512)
394 // We have to have at least len bytes + size of exponent.
395 if (len
< (num_length_bytes
+ exp_length
))
398 // The modulus is the remaining space.
399 modulus_length
= len
- (num_length_bytes
+ exp_length
);
401 // RFC3110 limits the modulus length to 4096 bits (512 octets).
402 if (modulus_length
> 512)
405 if (modulus_length
< 1)
408 // add 1 to modulus length for pre-ceding 0 t make ASN1 value non-negative
411 exponent
= &data
[num_length_bytes
];
412 modulus
= &data
[num_length_bytes
+ exp_length
];
414 // 2 bytes for commands since first doesn't count
415 // 2 bytes for min 1 byte length field
416 asn1_length
= modulus_length
+ exp_length
+ 2 + 2;
418 // Account for modulus length causing INT length field to grow.
419 if (modulus_length
>= 128)
421 if (modulus_length
> 255)
427 // Account for exponent length causing INT length field to grow.
428 if (exp_length
>= 128)
430 if (exp_length
> 255)
436 // Construct ASN1 formatted public key
437 // Write ASN1 SEQ byte
438 asn1
[index
++] = 0x30;
440 // Write ASN1 length for SEQ
441 if (asn1_length
< 128)
443 asn1
[index
++] = asn1_length
& 0xFF;
447 asn1
[index
++] = (0x80 | ((asn1_length
> 255) ? 2 : 1));
448 if (asn1_length
> 255)
449 asn1
[index
++] = (asn1_length
& 0xFF00) >> 8;
450 asn1
[index
++] = asn1_length
& 0xFF;
453 // Write ASN1 INT for modulus
454 asn1
[index
++] = 0x02;
455 // Write ASN1 length for INT
456 if (modulus_length
< 128)
458 asn1
[index
++] = modulus_length
& 0xFF;
462 asn1
[index
++] = 0x80 | ((modulus_length
> 255) ? 2 : 1);
463 if (modulus_length
> 255)
464 asn1
[index
++] = (modulus_length
& 0xFF00) >> 8;
465 asn1
[index
++] = modulus_length
& 0xFF;
468 // Write preceding 0 so our integer isn't negative
469 asn1
[index
++] = 0x00;
470 // Write actual modulus (-1 for preceding 0)
471 memcpy(&asn1
[index
], modulus
, modulus_length
- 1);
472 index
+= (modulus_length
- 1);
474 // Write ASN1 INT for exponent
475 asn1
[index
++] = 0x02;
476 // Write ASN1 length for INT
477 if (exp_length
< 128)
479 asn1
[index
++] = exp_length
& 0xFF;
483 asn1
[index
++] = 0x80 | ((exp_length
> 255) ? 2 : 1);
484 if (exp_length
> 255)
485 asn1
[index
++] = (exp_length
& 0xFF00) >> 8;
486 asn1
[index
++] = exp_length
& 0xFF;
488 // Write exponent bytes
489 memcpy(&asn1
[index
], exponent
, exp_length
);
493 // index contains bytes written, use it for length
494 return (SecKeyCreateRSAPublicKey(NULL
, asn1
, index
, kSecKeyEncodingPkcs1
));
496 return (SecKeyCreateRSAPublicKey_OSX(asn1
, index
));
501 mDNSlocal mStatus
rsa_sha_verify(AlgContext
*ctx
, mDNSu8
*key
, mDNSu32 keylen
, mDNSu8
*signature
, mDNSu32 siglen
)
505 mDNSu8 digest
[CC_SHA512_DIGEST_LENGTH
];
511 case CRYPTO_RSA_NSEC3_SHA1
:
512 case CRYPTO_RSA_SHA1
:
513 cryptoAlg
= kSecPaddingPKCS1SHA1
;
514 digestlen
= CC_SHA1_DIGEST_LENGTH
;
515 CC_SHA1_Final(digest
, (CC_SHA1_CTX
*)ctx
->context
);
517 case CRYPTO_RSA_SHA256
:
518 cryptoAlg
= kSecPaddingPKCS1SHA256
;
519 digestlen
= CC_SHA256_DIGEST_LENGTH
;
520 CC_SHA256_Final(digest
, (CC_SHA256_CTX
*)ctx
->context
);
522 case CRYPTO_RSA_SHA512
:
523 cryptoAlg
= kSecPaddingPKCS1SHA512
;
524 digestlen
= CC_SHA512_DIGEST_LENGTH
;
525 CC_SHA512_Final(digest
, (CC_SHA512_CTX
*)ctx
->context
);
528 LogMsg("rsa_sha_verify: Unsupported algorithm %d", ctx
->alg
);
529 return mStatus_BadParamErr
;
532 keyref
= rfc3110_import(key
, keylen
);
535 LogMsg("rsa_sha_verify: Error decoding rfc3110 key data");
536 return mStatus_NoMemoryErr
;
538 result
= SecKeyRawVerify(keyref
, cryptoAlg
, digest
, digestlen
, signature
, siglen
);
542 LogMsg("rsa_sha_verify: Failed for alg %d", ctx
->alg
);
543 return mStatus_BadParamErr
;
547 LogInfo("rsa_sha_verify: Passed for alg %d", ctx
->alg
);
548 return mStatus_NoError
;
551 #else // TARGET_OS_IPHONE
553 mDNSlocal SecKeyRef
SecKeyCreateRSAPublicKey_OSX(unsigned char *asn1
, int length
)
555 SecKeyRef result
= NULL
;
557 SecExternalFormat extFormat
= kSecFormatBSAFE
;
558 SecExternalItemType itemType
= kSecItemTypePublicKey
;
559 CFArrayRef outArray
= NULL
;
561 CFDataRef keyData
= CFDataCreate(NULL
, asn1
, length
);
565 OSStatus err
= SecItemImport(keyData
, NULL
, &extFormat
, &itemType
, 0, NULL
, NULL
, &outArray
);
568 if (noErr
!= err
|| outArray
== NULL
)
575 result
= (SecKeyRef
)CFArrayGetValueAtIndex(outArray
, 0);
587 mDNSlocal Boolean
VerifyData(SecKeyRef key
, CFStringRef digestStr
, mDNSu8
*digest
, int dlen
, int digestlenAttr
, mDNSu8
*sig
, int siglen
, CFStringRef digest_type
)
592 CFDataRef signature
= CFDataCreate(NULL
, sig
, siglen
);
596 SecTransformRef verifyXForm
= SecVerifyTransformCreate(key
, signature
, &error
);
597 CFRelease(signature
);
598 if (verifyXForm
== NULL
)
603 // tell the transform what type of data it is geting
604 if (!SecTransformSetAttribute(verifyXForm
, kSecInputIsAttributeName
, digest_type
, &error
))
606 LogMsg("VerifyData: SecTransformSetAttribute digest_type");
610 if (!SecTransformSetAttribute(verifyXForm
, kSecDigestTypeAttribute
, digestStr
, &error
))
612 LogMsg("VerifyData: SecTransformSetAttribute digestStr");
616 CFNumberRef digestLengthRef
= CFNumberCreate(kCFAllocatorDefault
, kCFNumberCFIndexType
, &digestlenAttr
);
617 if (digestLengthRef
== NULL
)
619 LogMsg("VerifyData: CFNumberCreate failed");
623 ret
= SecTransformSetAttribute(verifyXForm
, kSecDigestLengthAttribute
, digestLengthRef
, &error
);
624 CFRelease(digestLengthRef
);
627 LogMsg("VerifyData: SecTransformSetAttribute digestLengthRef");
631 CFDataRef dataToSign
= CFDataCreate(NULL
, digest
, dlen
);
632 if (dataToSign
== NULL
)
634 LogMsg("VerifyData: CFDataCreate failed");
638 ret
= SecTransformSetAttribute(verifyXForm
, kSecTransformInputAttributeName
, dataToSign
, &error
);
639 CFRelease(dataToSign
);
642 LogMsg("VerifyData: SecTransformSetAttribute TransformAttributeName");
646 CFBooleanRef boolRef
= SecTransformExecute(verifyXForm
, &error
);
647 ret
= boolRef
? CFBooleanGetValue(boolRef
) : false;
648 if (boolRef
) CFRelease(boolRef
);
649 CFRelease(verifyXForm
);
653 CFStringRef errStr
= CFErrorCopyDescription(error
);
658 if (!CFStringGetCString(errStr
, errorbuf
, sizeof(errorbuf
), kCFStringEncodingUTF8
))
660 LogMsg("VerifyData: CFStringGetCString failed");
664 LogMsg("VerifyData: SecTransformExecute failed with %s", errorbuf
);
669 CFRelease(verifyXForm
);
673 mDNSlocal mStatus
rsa_sha_verify(AlgContext
*ctx
, mDNSu8
*key
, mDNSu32 keylen
, mDNSu8
*signature
, mDNSu32 siglen
)
676 mDNSu8 digest
[CC_SHA512_DIGEST_LENGTH
];
679 CFStringRef digestStr
;
684 case CRYPTO_RSA_NSEC3_SHA1
:
685 case CRYPTO_RSA_SHA1
:
686 digestStr
= kSecDigestSHA1
;
687 digestlen
= CC_SHA1_DIGEST_LENGTH
;
689 CC_SHA1_Final(digest
, (CC_SHA1_CTX
*)ctx
->context
);
691 case CRYPTO_RSA_SHA256
:
692 digestStr
= kSecDigestSHA2
;
693 digestlen
= CC_SHA256_DIGEST_LENGTH
;
695 CC_SHA256_Final(digest
, (CC_SHA256_CTX
*)ctx
->context
);
697 case CRYPTO_RSA_SHA512
:
698 digestStr
= kSecDigestSHA2
;
699 digestlen
= CC_SHA512_DIGEST_LENGTH
;
701 CC_SHA512_Final(digest
, (CC_SHA512_CTX
*)ctx
->context
);
704 LogMsg("rsa_sha_verify: Unsupported algorithm %d", ctx
->alg
);
705 return mStatus_BadParamErr
;
708 keyref
= rfc3110_import(key
, keylen
);
711 LogMsg("rsa_sha_verify: Error decoding rfc3110 key data");
712 return mStatus_NoMemoryErr
;
714 ret
= VerifyData(keyref
, digestStr
, digest
, digestlen
, digestlenAttr
, signature
, siglen
, kSecInputIsDigest
);
718 LogMsg("rsa_sha_verify: Failed for alg %d", ctx
->alg
);
719 return mStatus_BadParamErr
;
723 LogInfo("rsa_sha_verify: Passed for alg %d", ctx
->alg
);
724 return mStatus_NoError
;
727 #endif // TARGET_OS_IPHONE
729 AlgFuncs sha_funcs
= {sha_create
, sha_destroy
, sha_len
, sha_add
, sha_verify
, mDNSNULL
, sha_final
};
730 AlgFuncs rsa_sha_funcs
= {rsa_sha_create
, rsa_sha_destroy
, rsa_sha_len
, rsa_sha_add
, rsa_sha_verify
, mDNSNULL
, mDNSNULL
};
731 AlgFuncs enc_funcs
= {enc_create
, enc_destroy
, mDNSNULL
, enc_add
, mDNSNULL
, enc_encode
, mDNSNULL
};
733 #ifndef DNSSEC_DISABLED
735 mDNSexport mStatus
DNSSECCryptoInit(mDNS
*const m
)
739 result
= DigestAlgInit(SHA1_DIGEST_TYPE
, &sha_funcs
);
740 if (result
!= mStatus_NoError
)
742 result
= DigestAlgInit(SHA256_DIGEST_TYPE
, &sha_funcs
);
743 if (result
!= mStatus_NoError
)
745 result
= CryptoAlgInit(CRYPTO_RSA_SHA1
, &rsa_sha_funcs
);
746 if (result
!= mStatus_NoError
)
748 result
= CryptoAlgInit(CRYPTO_RSA_NSEC3_SHA1
, &rsa_sha_funcs
);
749 if (result
!= mStatus_NoError
)
751 result
= CryptoAlgInit(CRYPTO_RSA_SHA256
, &rsa_sha_funcs
);
752 if (result
!= mStatus_NoError
)
754 result
= CryptoAlgInit(CRYPTO_RSA_SHA512
, &rsa_sha_funcs
);
755 if (result
!= mStatus_NoError
)
757 result
= EncAlgInit(ENC_BASE32
, &enc_funcs
);
758 if (result
!= mStatus_NoError
)
760 result
= EncAlgInit(ENC_BASE64
, &enc_funcs
);
761 if (result
!= mStatus_NoError
)
764 result
= DNSSECPlatformInit(m
);
769 #else // !DNSSEC_DISABLED
771 mDNSexport mStatus
DNSSECCryptoInit(mDNS
*const m
)
775 return mStatus_NoError
;
778 #endif // !DNSSEC_DISABLED