Reorganize private crypto header files
[openssl.git] / crypto / dh / dh_rfc7919.c
index d01ba6fdf3c9510ad170b70a34546a92319f3dc7..d634dbc37614bd130ba10dd765a78fe613b21057 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
@@ -12,7 +12,7 @@
 #include "dh_locl.h"
 #include <openssl/bn.h>
 #include <openssl/objects.h>
-#include "internal/bn_dh.h"
+#include "crypto/bn_dh.h"
 
 static DH *dh_param_init(const BIGNUM *p, int32_t nbits)
 {
@@ -22,6 +22,7 @@ static DH *dh_param_init(const BIGNUM *p, int32_t nbits)
     dh->p = (BIGNUM *)p;
     dh->g = (BIGNUM *)&_bignum_const_2;
     dh->length = nbits;
+    dh->dirty_cnt++;
     return dh;
 }
 
@@ -66,10 +67,9 @@ int DH_get_nid(const DH *dh)
         BIGNUM *q = BN_dup(dh->p);
 
         /* Check q = p * 2 + 1 we already know q is odd, so just shift right */
-        if (q == NULL || !BN_rshift1(q, q) || !BN_cmp(dh->q, q)) {
-            BN_free(q);
-            return NID_undef;
-        }
+        if (q == NULL || !BN_rshift1(q, q) || !BN_cmp(dh->q, q))
+            nid = NID_undef;
+        BN_free(q);
     }
     return nid;
 }