]> git.saurik.com Git - apple/xnu.git/blobdiff - EXTERNAL_HEADERS/corecrypto/ccasn1.h
xnu-4570.71.2.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / corecrypto / ccasn1.h
index 7fe1cc66c6ce94959c22b59a0e8d1ac3c8e6fe0f..28fba4eef86a1c0045daf16898e43df50e1f58e0 100644 (file)
@@ -69,9 +69,15 @@ enum {
     CCASN1_CONSTRUCTED_SEQUENCE = CCASN1_SEQUENCE | CCASN1_CONSTRUCTED,
 };
 
+#if CORECRYPTO_USE_TRANSPARENT_UNION
 typedef union {
-    const unsigned char *oid;
-} ccoid_t __attribute__((transparent_union));
+    const unsigned char * oid;
+} __attribute__((transparent_union)) ccoid_t;
+#define CCOID(x) ((x).oid)
+#else
+    typedef const unsigned char * ccoid_t;
+#define CCOID(oid) (oid)
+#endif
 
 /* Returns *der iff *der points to a DER encoded oid that fits within *der_len. */
 ccoid_t ccoid_for_der(size_t *der_len, const uint8_t **der);
@@ -79,14 +85,13 @@ ccoid_t ccoid_for_der(size_t *der_len, const uint8_t **der);
 /* Returns the size of an oid including it's tag and length. */
 CC_INLINE CC_PURE CC_NONNULL_TU((1))
 size_t ccoid_size(ccoid_t oid) {
-    return 2 + oid.oid[1];
+    return 2 + CCOID(oid)[1];
 }
 
 CC_INLINE CC_PURE CC_NONNULL_TU((1)) CC_NONNULL_TU((2))
 bool ccoid_equal(ccoid_t oid1, ccoid_t oid2) {
-    return(ccoid_size(oid1) == ccoid_size(oid2) && memcmp(oid1.oid, oid2.oid, ccoid_size(oid1))== 0);
+    return  (ccoid_size(oid1) == ccoid_size(oid2)
+            && memcmp(CCOID(oid1), CCOID(oid2), ccoid_size(oid1))== 0);
 }
 
-extern const unsigned char *ccsha1_oid;
-
 #endif /* _CORECRYPTO_CCASN1_H_ */