Home | History | Annotate | Line # | Download | only in man3
      1      1.1  christos =pod
      2      1.1  christos 
      3      1.1  christos =head1 NAME
      4      1.1  christos 
      5  1.1.1.2  christos DH_generate_key, DH_compute_key, DH_compute_key_padded - perform
      6  1.1.1.2  christos Diffie-Hellman key exchange
      7      1.1  christos 
      8      1.1  christos =head1 SYNOPSIS
      9      1.1  christos 
     10      1.1  christos  #include <openssl/dh.h>
     11      1.1  christos 
     12  1.1.1.3  christos The following functions have been deprecated since OpenSSL 3.0, and can be
     13  1.1.1.3  christos hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
     14  1.1.1.3  christos see L<openssl_user_macros(7)>:
     15  1.1.1.3  christos 
     16      1.1  christos  int DH_generate_key(DH *dh);
     17      1.1  christos 
     18  1.1.1.2  christos  int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
     19  1.1.1.2  christos 
     20  1.1.1.2  christos  int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);
     21      1.1  christos 
     22      1.1  christos =head1 DESCRIPTION
     23      1.1  christos 
     24  1.1.1.3  christos All of the functions described on this page are deprecated.
     25  1.1.1.3  christos Applications should instead use L<EVP_PKEY_derive_init(3)>
     26  1.1.1.3  christos and L<EVP_PKEY_derive(3)>.
     27  1.1.1.3  christos 
     28      1.1  christos DH_generate_key() performs the first step of a Diffie-Hellman key
     29      1.1  christos exchange by generating private and public DH values. By calling
     30  1.1.1.2  christos DH_compute_key() or DH_compute_key_padded(), these are combined with
     31  1.1.1.2  christos the other party's public value to compute the shared key.
     32      1.1  christos 
     33      1.1  christos DH_generate_key() expects B<dh> to contain the shared parameters
     34      1.1  christos B<dh-E<gt>p> and B<dh-E<gt>g>. It generates a random private DH value
     35      1.1  christos unless B<dh-E<gt>priv_key> is already set, and computes the
     36      1.1  christos corresponding public value B<dh-E<gt>pub_key>, which can then be
     37      1.1  christos published.
     38      1.1  christos 
     39      1.1  christos DH_compute_key() computes the shared secret from the private DH value
     40      1.1  christos in B<dh> and the other party's public value in B<pub_key> and stores
     41      1.1  christos it in B<key>. B<key> must point to B<DH_size(dh)> bytes of memory.
     42  1.1.1.2  christos The padding style is RFC 5246 (8.1.2) that strips leading zero bytes.
     43  1.1.1.2  christos It is not constant time due to the leading zero bytes being stripped.
     44  1.1.1.2  christos The return value should be considered public.
     45  1.1.1.2  christos 
     46  1.1.1.2  christos DH_compute_key_padded() is similar but stores a fixed number of bytes.
     47  1.1.1.2  christos The padding style is NIST SP 800-56A (C.1) that retains leading zero bytes.
     48  1.1.1.2  christos It is constant time due to the leading zero bytes being retained.
     49  1.1.1.2  christos The return value should be considered public.
     50      1.1  christos 
     51      1.1  christos =head1 RETURN VALUES
     52      1.1  christos 
     53      1.1  christos DH_generate_key() returns 1 on success, 0 otherwise.
     54      1.1  christos 
     55      1.1  christos DH_compute_key() returns the size of the shared secret on success, -1
     56      1.1  christos on error.
     57      1.1  christos 
     58  1.1.1.2  christos DH_compute_key_padded() returns B<DH_size(dh)> on success, -1 on error.
     59  1.1.1.2  christos 
     60      1.1  christos The error codes can be obtained by L<ERR_get_error(3)>.
     61      1.1  christos 
     62      1.1  christos =head1 SEE ALSO
     63      1.1  christos 
     64  1.1.1.3  christos L<EVP_PKEY_derive(3)>,
     65      1.1  christos L<DH_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>, L<DH_size(3)>
     66      1.1  christos 
     67  1.1.1.2  christos =head1 HISTORY
     68  1.1.1.2  christos 
     69  1.1.1.2  christos DH_compute_key_padded() was added in OpenSSL 1.0.2.
     70  1.1.1.2  christos 
     71  1.1.1.3  christos All of these functions were deprecated in OpenSSL 3.0.
     72  1.1.1.3  christos 
     73      1.1  christos =head1 COPYRIGHT
     74      1.1  christos 
     75  1.1.1.2  christos Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
     76      1.1  christos 
     77  1.1.1.3  christos Licensed under the Apache License 2.0 (the "License").  You may not use
     78      1.1  christos this file except in compliance with the License.  You can obtain a copy
     79      1.1  christos in the file LICENSE in the source distribution or at
     80      1.1  christos L<https://www.openssl.org/source/license.html>.
     81      1.1  christos 
     82      1.1  christos =cut
     83