#include <openssl/rsa.h>
EVP_PKEY_CTX *ctx;
+ ENGINE *eng;
unsigned char *skey;
size_t skeylen;
EVP_PKEY *pkey, *peerkey;
- /* NB: assumes pkey, peerkey have been already set up */
+ /* NB: assumes pkey, eng, peerkey have been already set up */
- ctx = EVP_PKEY_CTX_new(pkey);
+ ctx = EVP_PKEY_CTX_new(pkey, eng);
if (!ctx)
- /* Error occurred */
+ /* Error occurred */
if (EVP_PKEY_derive_init(ctx) <= 0)
- /* Error */
+ /* Error */
if (EVP_PKEY_derive_set_peer(ctx, peerkey) <= 0)
- /* Error */
+ /* Error */
/* Determine buffer length */
if (EVP_PKEY_derive(ctx, NULL, &skeylen) <= 0)
- /* Error */
+ /* Error */
skey = OPENSSL_malloc(skeylen);
if (!skey)
- /* malloc failure */
+ /* malloc failure */
if (EVP_PKEY_derive(ctx, skey, &skeylen) <= 0)
- /* Error */
+ /* Error */
/* Shared secret is skey bytes written to buffer skey */
=head1 HISTORY
-These functions were first added to OpenSSL 1.0.0.
+These functions were added in OpenSSL 1.0.0.
=head1 COPYRIGHT
-Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2006-2018 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
L<https://www.openssl.org/source/license.html>.