]> git.saurik.com Git - apple/security.git/blobdiff - OSX/sec/Security/Regressions/vmdh/vmdh-42-example2.c
Security-58286.1.32.tar.gz
[apple/security.git] / OSX / sec / Security / Regressions / vmdh / vmdh-42-example2.c
index 345cee705366cd8662745f6cc807939f03faa2e0..3c79e75ec7508a1015a9c9881593488e4372aaa2 100644 (file)
 #endif
 
 /* How to reach in the internals of SecDH/vmdh struct */
+//these are copies of SecDH_gp() and SecDH_priv()
 static inline ccdh_gp_t vmdh_gp(struct vmdh *dh)
 {
-    ccdh_gp_t gp;
-    gp.gp  = (ccdh_gp *)dh;
-    return gp;
+    return  (ccdh_gp_t)dh;
 }
 
 static inline ccdh_full_ctx_t vmdh_priv(struct vmdh *dh)
 {
-    void *p = dh;
-    cczp_t zp;
-    zp.zp = (struct cczp *) dh;
-    cc_size s = ccn_sizeof_n(cczp_n(zp));
-    ccdh_full_ctx_t priv = { .hdr = (struct ccdh_ctx_header *)(p+ccdh_gp_size(s)) };
+    ccdh_gp_t gp = vmdh_gp(dh);
+    cc_size s = ccn_sizeof_n(ccdh_gp_n(gp));
+    ccdh_full_ctx_t priv = (ccdh_full_ctx_t)((char *) dh + ccdh_gp_size(s));
     return priv;
 }
 
@@ -107,7 +105,6 @@ static void tests(void)
     /* No SecDH API to import a private key, so we have to reach inside the opaque struct */
     ccdh_gp_t gp = vmdh_gp(vmdh);
     ccdh_full_ctx_t priv = vmdh_priv(vmdh);
-
     ok_status(ccdh_import_priv(gp, sizeof(client_priv), client_priv, priv), "Import DH private key");
 
     uint8_t encpw[vmdh_encpw_len(sizeof(pw))];