blob: 2933b2f5c09715d2cc0505872e0e713f99390502 [file] [log] [blame]
Paul Bakkerbdb912d2012-02-13 23:11:30 +00001/**
2 * \file x509write.h
3 *
4 * \brief X509 buffer writing functionality
5 *
Paul Bakker407a0da2013-06-27 14:29:21 +02006 * Copyright (C) 2006-2013, Brainspark B.V.
Paul Bakkerbdb912d2012-02-13 23:11:30 +00007 *
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 Bakkerbc956d92013-04-19 14:51:29 +020030#include "config.h"
31
Paul Bakkerbdb912d2012-02-13 23:11:30 +000032#include "rsa.h"
33
Paul Bakker0e06c0f2013-08-25 11:21:30 +020034#define POLARSSL_ERR_X509WRITE_UNKNOWN_OID -0x5F80 /**< Requested OID is unknown. */
35#define POLARSSL_ERR_X509WRITE_BAD_INPUT_DATA -0x5F00 /**< Failed to allocate memory. */
36#define POLARSSL_ERR_X509WRITE_MALLOC_FAILED -0x5E80 /**< Failed to allocate memory. */
37
Paul Bakker8eabfc12013-08-25 10:18:25 +020038
Paul Bakker407a0da2013-06-27 14:29:21 +020039#ifdef __cplusplus
40extern "C" {
41#endif
42
Paul Bakkerbdb912d2012-02-13 23:11:30 +000043typedef struct _x509_req_name
44{
45 char oid[128];
46 char name[128];
47
48 struct _x509_req_name *next;
49}
50x509_req_name;
51
Paul Bakker82e29452013-08-25 11:01:31 +020052typedef struct _x509_csr
Paul Bakker8eabfc12013-08-25 10:18:25 +020053{
54 rsa_context *rsa;
55 x509_req_name *subject;
56 md_type_t md_alg;
57}
Paul Bakker82e29452013-08-25 11:01:31 +020058x509_csr;
Paul Bakker8eabfc12013-08-25 10:18:25 +020059
Paul Bakker82e29452013-08-25 11:01:31 +020060void x509write_csr_init( x509_csr *ctx );
61int x509write_csr_set_subject_name( x509_csr *ctx, char *subject_name );
62void x509write_csr_set_rsa_key( x509_csr *ctx, rsa_context *rsa );
63void x509write_csr_set_md_alg( x509_csr *ctx, md_type_t md_alg );
64void x509write_csr_free( x509_csr *ctx );
Paul Bakker8eabfc12013-08-25 10:18:25 +020065
Paul Bakker82e29452013-08-25 11:01:31 +020066int x509write_pubkey_der( rsa_context *rsa, unsigned char *buf, size_t size );
67int x509write_key_der( rsa_context *rsa, unsigned char *buf, size_t size );
68int x509write_csr_der( x509_csr *ctx, unsigned char *buf, size_t size );
Paul Bakkerbdb912d2012-02-13 23:11:30 +000069
Paul Bakker407a0da2013-06-27 14:29:21 +020070#ifdef __cplusplus
71}
72#endif
73
Paul Bakkerbdb912d2012-02-13 23:11:30 +000074#endif /* POLARSSL_X509_WRITE_H */