s4:heimdal: import lorikeet-heimdal-201001120029 (commit a5e675fed7c5db8a7370b77ed0bf...
[samba.git] / source4 / heimdal / lib / hcrypto / evp-cc.c
index 15b3479f8ed7fc81a48d8d3726030c079fe347f9..f1da22537df3dbe4d44fd46e81418081f42563bf 100644 (file)
@@ -3,6 +3,8 @@
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
+ * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -43,7 +45,9 @@
 #include <string.h>
 #include <assert.h>
 
+#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
 #include <CommonCrypto/CommonDigest.h>
+#endif
 #include <CommonCrypto/CommonCryptor.h>
 
 #include <evp.h>
@@ -420,6 +424,7 @@ EVP_cc_rc2_64_cbc(void)
 const EVP_MD *
 EVP_cc_md2(void)
 {
+#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
     static const struct hc_evp_md md2 = {
        CC_MD2_DIGEST_LENGTH,
        CC_MD2_BLOCK_BYTES,
@@ -430,6 +435,9 @@ EVP_cc_md2(void)
        (hc_evp_md_cleanup)NULL
     };
     return &md2;
+#else
+    return NULL;
+#endif
 }
 
 /**
@@ -441,6 +449,7 @@ EVP_cc_md2(void)
 const EVP_MD *
 EVP_cc_md4(void)
 {
+#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
     static const struct hc_evp_md md4 = {
        CC_MD4_DIGEST_LENGTH,
        CC_MD4_BLOCK_BYTES,
@@ -451,6 +460,9 @@ EVP_cc_md4(void)
        (hc_evp_md_cleanup)NULL
     };
     return &md4;
+#else
+    return NULL;
+#endif
 }
 
 /**
@@ -462,6 +474,7 @@ EVP_cc_md4(void)
 const EVP_MD *
 EVP_cc_md5(void)
 {
+#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
     static const struct hc_evp_md md5 = {
        CC_MD5_DIGEST_LENGTH,
        CC_MD5_BLOCK_BYTES,
@@ -472,6 +485,9 @@ EVP_cc_md5(void)
        (hc_evp_md_cleanup)NULL
     };
     return &md5;
+#else
+    return NULL;
+#endif
 }
 
 /**
@@ -483,6 +499,7 @@ EVP_cc_md5(void)
 const EVP_MD *
 EVP_cc_sha1(void)
 {
+#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
     static const struct hc_evp_md sha1 = {
        CC_SHA1_DIGEST_LENGTH,
        CC_SHA1_BLOCK_BYTES,
@@ -493,6 +510,9 @@ EVP_cc_sha1(void)
        (hc_evp_md_cleanup)NULL
     };
     return &sha1;
+#else
+    return NULL;
+#endif
 }
 
 /**
@@ -504,6 +524,7 @@ EVP_cc_sha1(void)
 const EVP_MD *
 EVP_cc_sha256(void)
 {
+#ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
     static const struct hc_evp_md sha256 = {
        CC_SHA256_DIGEST_LENGTH,
        CC_SHA256_BLOCK_BYTES,
@@ -514,6 +535,9 @@ EVP_cc_sha256(void)
        (hc_evp_md_cleanup)NULL
     };
     return &sha256;
+#else
+    return NULL;
+#endif
 }
 
 /**