blob: c95172f57baf739ac1fb6c3b52ef973b7331ed33 [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 Bakker8eabfc12013-08-25 10:18:25 +020034#define POLARSSL_ERR_X509_WRITE_UNKNOWN_OID -1
35#define POLARSSL_ERR_X509_WRITE_BAD_INPUT_DATA -1
36#define POLARSSL_ERR_X509_WRITE_MALLOC_FAILED -1
37
Paul Bakker407a0da2013-06-27 14:29:21 +020038#ifdef __cplusplus
39extern "C" {
40#endif
41
Paul Bakkerbdb912d2012-02-13 23:11:30 +000042typedef struct _x509_req_name
43{
44 char oid[128];
45 char name[128];
46
47 struct _x509_req_name *next;
48}
49x509_req_name;
50
Paul Bakker82e29452013-08-25 11:01:31 +020051typedef struct _x509_csr
Paul Bakker8eabfc12013-08-25 10:18:25 +020052{
53 rsa_context *rsa;
54 x509_req_name *subject;
55 md_type_t md_alg;
56}
Paul Bakker82e29452013-08-25 11:01:31 +020057x509_csr;
Paul Bakker8eabfc12013-08-25 10:18:25 +020058
Paul Bakker82e29452013-08-25 11:01:31 +020059void x509write_csr_init( x509_csr *ctx );
60int x509write_csr_set_subject_name( x509_csr *ctx, char *subject_name );
61void x509write_csr_set_rsa_key( x509_csr *ctx, rsa_context *rsa );
62void x509write_csr_set_md_alg( x509_csr *ctx, md_type_t md_alg );
63void x509write_csr_free( x509_csr *ctx );
Paul Bakker8eabfc12013-08-25 10:18:25 +020064
Paul Bakker82e29452013-08-25 11:01:31 +020065int x509write_pubkey_der( rsa_context *rsa, unsigned char *buf, size_t size );
66int x509write_key_der( rsa_context *rsa, unsigned char *buf, size_t size );
67int x509write_csr_der( x509_csr *ctx, unsigned char *buf, size_t size );
Paul Bakkerbdb912d2012-02-13 23:11:30 +000068
Paul Bakker407a0da2013-06-27 14:29:21 +020069#ifdef __cplusplus
70}
71#endif
72
Paul Bakkerbdb912d2012-02-13 23:11:30 +000073#endif /* POLARSSL_X509_WRITE_H */