5 // Created by Martin Baulig on 3/7/16.
6 // Copyright © 2016 Xamarin. All rights reserved.
14 return EVP_PKEY_new ();
18 mono_btls_key_free (EVP_PKEY
*pkey
)
24 mono_btls_key_up_ref (EVP_PKEY
*pkey
)
26 return EVP_PKEY_up_ref (pkey
);
30 mono_btls_key_get_bits (EVP_PKEY
*pkey
)
32 return EVP_PKEY_bits (pkey
);
36 mono_btls_key_is_rsa (EVP_PKEY
*pkey
)
38 return pkey
->type
== EVP_PKEY_RSA
;
42 mono_btls_key_assign_rsa_private_key (EVP_PKEY
*pkey
, uint8_t *der_data
, int der_length
)
46 rsa
= RSA_private_key_from_bytes (der_data
, der_length
);
50 return EVP_PKEY_assign_RSA (pkey
, rsa
);
54 mono_btls_key_get_bytes (EVP_PKEY
*pkey
, uint8_t **buffer
, int *size
, int include_private_bits
)
63 if (pkey
->type
!= EVP_PKEY_RSA
)
66 rsa
= EVP_PKEY_get1_RSA (pkey
);
70 if (include_private_bits
)
71 ret
= RSA_private_key_to_bytes (buffer
, &len
, rsa
);
73 ret
= RSA_public_key_to_bytes (buffer
, &len
, rsa
);