2016-05-18 03:38:09 +08:00
|
|
|
/*
|
2020-04-23 20:55:52 +08:00
|
|
|
* Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
|
2002-12-08 13:24:31 +08:00
|
|
|
*
|
2018-12-06 20:36:05 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 03:38:09 +08:00
|
|
|
* 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
|
2002-12-08 13:24:31 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* This file contains deprecated functions as wrappers to the new ones */
|
|
|
|
|
2020-02-03 17:05:31 +08:00
|
|
|
/*
|
|
|
|
* DH low level APIs are deprecated for public use, but still ok for
|
|
|
|
* internal use.
|
|
|
|
*/
|
|
|
|
#include "internal/deprecated.h"
|
|
|
|
|
2016-01-05 12:00:33 +08:00
|
|
|
#include <openssl/opensslconf.h>
|
2002-12-08 13:24:31 +08:00
|
|
|
|
2020-03-06 01:50:31 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "internal/cryptlib.h"
|
|
|
|
#include <openssl/bn.h>
|
|
|
|
#include <openssl/dh.h>
|
2003-10-29 12:06:50 +08:00
|
|
|
|
2002-12-08 13:24:31 +08:00
|
|
|
DH *DH_generate_parameters(int prime_len, int generator,
|
2015-01-22 11:40:55 +08:00
|
|
|
void (*callback) (int, int, void *), void *cb_arg)
|
|
|
|
{
|
|
|
|
BN_GENCB *cb;
|
|
|
|
DH *ret = NULL;
|
2002-12-08 13:24:31 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
if ((ret = DH_new()) == NULL)
|
|
|
|
return NULL;
|
|
|
|
cb = BN_GENCB_new();
|
2015-10-30 19:12:26 +08:00
|
|
|
if (cb == NULL) {
|
2015-01-22 11:40:55 +08:00
|
|
|
DH_free(ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-12-08 13:24:31 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
BN_GENCB_set_old(cb, callback, cb_arg);
|
2002-12-08 13:24:31 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
if (DH_generate_parameters_ex(ret, prime_len, generator, cb)) {
|
|
|
|
BN_GENCB_free(cb);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
BN_GENCB_free(cb);
|
|
|
|
DH_free(ret);
|
|
|
|
return NULL;
|
|
|
|
}
|