Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file x509write.h |
| 3 | * |
| 4 | * \brief X509 buffer writing functionality |
| 5 | * |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 6 | * Copyright (C) 2006-2013, Brainspark B.V. |
Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 7 | * |
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 10 | * |
| 11 | * All rights reserved. |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2 of the License, or |
| 16 | * (at your option) any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License along |
| 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 26 | */ |
| 27 | #ifndef POLARSSL_X509_WRITE_H |
| 28 | #define POLARSSL_X509_WRITE_H |
| 29 | |
Paul Bakker | bc956d9 | 2013-04-19 14:51:29 +0200 | [diff] [blame] | 30 | #include "config.h" |
| 31 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 32 | #if defined(POLARSSL_X509_WRITE_C) |
| 33 | |
Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 34 | #include "rsa.h" |
| 35 | |
Paul Bakker | 8eabfc1 | 2013-08-25 10:18:25 +0200 | [diff] [blame^] | 36 | #define POLARSSL_ERR_X509_WRITE_UNKNOWN_OID -1 |
| 37 | #define POLARSSL_ERR_X509_WRITE_BAD_INPUT_DATA -1 |
| 38 | #define POLARSSL_ERR_X509_WRITE_MALLOC_FAILED -1 |
| 39 | |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 40 | #ifdef __cplusplus |
| 41 | extern "C" { |
| 42 | #endif |
| 43 | |
Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 44 | typedef struct _x509_req_name |
| 45 | { |
| 46 | char oid[128]; |
| 47 | char name[128]; |
| 48 | |
| 49 | struct _x509_req_name *next; |
| 50 | } |
| 51 | x509_req_name; |
| 52 | |
Paul Bakker | 8eabfc1 | 2013-08-25 10:18:25 +0200 | [diff] [blame^] | 53 | typedef struct _x509_cert_req |
| 54 | { |
| 55 | rsa_context *rsa; |
| 56 | x509_req_name *subject; |
| 57 | md_type_t md_alg; |
| 58 | } |
| 59 | x509_cert_req; |
| 60 | |
| 61 | void x509cert_req_init( x509_cert_req *ctx ); |
| 62 | int x509cert_req_set_subject_name( x509_cert_req *ctx, char *subject_name ); |
| 63 | void x509cert_req_set_rsa_key( x509_cert_req *ctx, rsa_context *rsa ); |
| 64 | void x509cert_req_set_md_alg( x509_cert_req *ctx, md_type_t md_alg ); |
| 65 | void x509cert_req_free( x509_cert_req *ctx ); |
| 66 | |
Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 67 | int x509_write_pubkey_der( unsigned char *buf, size_t size, rsa_context *rsa ); |
| 68 | int x509_write_key_der( unsigned char *buf, size_t size, rsa_context *rsa ); |
Paul Bakker | 8eabfc1 | 2013-08-25 10:18:25 +0200 | [diff] [blame^] | 69 | int x509_write_cert_req( x509_cert_req *ctx, unsigned char *buf, size_t size ); |
Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 70 | |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 71 | #ifdef __cplusplus |
| 72 | } |
| 73 | #endif |
| 74 | |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 75 | #endif /* POLARSSL_X509_WRITE_C */ |
| 76 | |
Paul Bakker | bdb912d | 2012-02-13 23:11:30 +0000 | [diff] [blame] | 77 | #endif /* POLARSSL_X509_WRITE_H */ |