[BACK]Return to dh.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / openssl

Diff for /src/usr.bin/openssl/dh.c between version 1.12 and 1.13

version 1.12, 2019/07/14 03:30:45 version 1.13, 2022/01/14 09:21:54
Line 234 
Line 234 
                 unsigned char *data;                  unsigned char *data;
                 int len, l, bits;                  int len, l, bits;
   
                 len = BN_num_bytes(dh->p);                  len = BN_num_bytes(DH_get0_p(dh));
                 bits = BN_num_bits(dh->p);                  bits = BN_num_bits(DH_get0_p(dh));
                 data = malloc(len);                  data = malloc(len);
                 if (data == NULL) {                  if (data == NULL) {
                         perror("malloc");                          perror("malloc");
                         goto end;                          goto end;
                 }                  }
                 l = BN_bn2bin(dh->p, data);                  l = BN_bn2bin(DH_get0_p(dh), data);
                 printf("static unsigned char dh%d_p[] = {", bits);                  printf("static unsigned char dh%d_p[] = {", bits);
                 for (i = 0; i < l; i++) {                  for (i = 0; i < l; i++) {
                         if ((i % 12) == 0)                          if ((i % 12) == 0)
Line 250 
Line 250 
                 }                  }
                 printf("\n\t};\n");                  printf("\n\t};\n");
   
                 l = BN_bn2bin(dh->g, data);                  l = BN_bn2bin(DH_get0_g(dh), data);
                 printf("static unsigned char dh%d_g[] = {", bits);                  printf("static unsigned char dh%d_g[] = {", bits);
                 for (i = 0; i < l; i++) {                  for (i = 0; i < l; i++) {
                         if ((i % 12) == 0)                          if ((i % 12) == 0)
Line 260 
Line 260 
                 printf("\n\t};\n\n");                  printf("\n\t};\n\n");
   
                 printf("DH *get_dh%d()\n\t{\n", bits);                  printf("DH *get_dh%d()\n\t{\n", bits);
                 printf("\tDH *dh;\n\n");                  printf("\tDH *dh;\n");
                   printf("\tBIGNUM *p = NULL, *g = NULL;\n\n");
                 printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n");                  printf("\tif ((dh = DH_new()) == NULL) return(NULL);\n");
                 printf("\tdh->p = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n",                  printf("\tp = BN_bin2bn(dh%d_p, sizeof(dh%d_p), NULL);\n",
                     bits, bits);                      bits, bits);
                 printf("\tdh->g = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n",                  printf("\tg = BN_bin2bn(dh%d_g, sizeof(dh%d_g), NULL);\n",
                     bits, bits);                      bits, bits);
                 printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");                  printf("\tif (p == NULL || g == NULL)\n");
                 printf("\t\treturn(NULL);\n");                  printf("\t\t{ BN_free(p); BN_free(q); DH_free(dh); return(NULL); }\n");
                   printf("\tDH_set0_pqg(dh, p, NULL, g);\n");
                 printf("\treturn(dh);\n\t}\n");                  printf("\treturn(dh);\n\t}\n");
                 free(data);                  free(data);
         }          }

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13