1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef _SSL_PKEY_H_ 16 #define _SSL_PKEY_H_ 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 #include "ssl_types.h" 23 24 /** 25 * @brief create a private key object according to input private key 26 * 27 * @param ipk - input private key point 28 * 29 * @return new private key object point 30 */ 31 EVP_PKEY* __EVP_PKEY_new(EVP_PKEY *ipk, void *rngctx); 32 33 /** 34 * @brief create a private key object 35 * 36 * @param none 37 * 38 * @return private key object point 39 */ 40 EVP_PKEY* EVP_PKEY_new(void *rngctx); 41 42 /** 43 * @brief load a character key context into system context. If '*a' is pointed to the 44 * private key, then load key into it. Or create a new private key object 45 * 46 * @param type - private key type 47 * @param a - a point pointed to a private key point 48 * @param pp - a point pointed to the key context memory point 49 * @param length - key bytes 50 * 51 * @return private key object point 52 */ 53 EVP_PKEY* d2i_PrivateKey(int type, 54 EVP_PKEY **a, 55 const unsigned char **pp, 56 long length, void *rngctx); 57 58 /** 59 * @brief free a private key object 60 * 61 * @param pkey - private key object point 62 * 63 * @return none 64 */ 65 void EVP_PKEY_free(EVP_PKEY *x); 66 67 /** 68 * @brief load private key into the SSL 69 * 70 * @param type - private key type 71 * @param ssl - SSL point 72 * @param len - data bytes 73 * @param d - data point 74 * 75 * @return result 76 * 0 : failed 77 * 1 : OK 78 */ 79 int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, const unsigned char *d, long len); 80 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif 87