1/* 2 * Copyright (c) 2011-12 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef _OSSL_PEM_H_ 25#define _OSSL_PEM_H_ 26 27#include "ossl-bio.h" 28 29#define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" 30#define PEM_STRING_RSA "RSA PRIVATE KEY" 31#define PEM_STRING_DSA "DSA PRIVATE KEY" 32#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" 33#define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" 34#define PEM_STRING_PUBLIC "PUBLIC KEY" 35 36#define PEM_BUFSIZE 1024 37 38#define PEM_TYPE_ENCRYPTED 10 39#define PEM_TYPE_MIC_ONLY 20 40#define PEM_TYPE_MIC_CLEAR 30 41#define PEM_TYPE_CLEAR 40 42 43/* Rewrite symbols */ 44#define PEM_bytes_read_bio ossl_PEM_bytes_read_bio 45 46#define PEM_read_bio ossl_PEM_read_bio 47#define PEM_read_bio_PrivateKey ossl_PEM_read_bio_PrivateKey 48 49#define PEM_write_bio_RSAPrivateKey ossl_PEM_write_bio_RSAPrivateKey 50#define PEM_write_bio_DSAPrivateKey ossl_PEM_write_bio_DSAPrivateKey 51#define PEM_do_header ossl_PEM_do_header 52#define PEM_get_EVP_CIPHER_INFO ossl_PEM_get_EVP_CIPHER_INFO 53#define PEM_write_RSAPrivateKey ossl_PEM_write_RSAPrivateKey 54#define PEM_write_DSAPrivateKey ossl_PEM_write_DSAPrivateKey 55 56#define PEM_read_PUBKEY ossl_PEM_read_PUBKEY 57#define PEM_write_DSA_PUBKEY ossl_PEM_write_DSA_PUBKEY 58#define PEM_write_RSA_PUBKEY ossl_PEM_write_RSA_PUBKEY 59 60typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata); 61 62int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc, 63 unsigned char *kstr, int klen, pem_password_cb *cb, void *u); 64 65int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc, 66 unsigned char *kstr, int klen, pem_password_cb *cb, void *u); 67 68int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, const char *name, BIO *bp, 69 pem_password_cb *cb, void *u); 70int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data, long *len); 71EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); 72int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len, 73 pem_password_cb *callback, void *u); 74int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); 75RSA *PEM_read_RSAPublicKey(FILE *fp, RSA *rsa, pem_password_cb *cb, void *u); 76int PEM_write_RSAPrivateKey(FILE *fp, RSA *rsa, const EVP_CIPHER *enc, unsigned char *kstr, 77 int klen, pem_password_cb *callback, void *u); 78int PEM_write_DSAPrivateKey(FILE *fp, DSA *dsa, const EVP_CIPHER *enc, unsigned char *kstr, 79 int klen, pem_password_cb *callback, void *u); 80 81EVP_PKEY *PEM_read_PUBKEY(FILE *fp, EVP_PKEY **pkey, pem_password_cb *cb, void *u); 82int PEM_write_DSA_PUBKEY(FILE *fp, DSA *dsa); 83int PEM_write_RSA_PUBKEY(FILE *fp, RSA *dsa); 84 85#endif /* _OSSL_PEM_H_ */ 86