mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-03 13:15:42 +01:00
- Added preliminary ASN.1 buffer writing support
- Added preliminary X509 Certificate Request writing support - Added key_app_writer example application - Added cert_req example application
This commit is contained in:
parent
048d04ef4b
commit
bdb912db69
16 changed files with 1245 additions and 12 deletions
|
|
@ -47,12 +47,12 @@
|
|||
* ASN1 is a standard to specify data structures.
|
||||
* \{
|
||||
*/
|
||||
#define POLARSSL_ERR_ASN1_OUT_OF_DATA -0x0014 /**< Out of data when parsing an ASN1 data structure. */
|
||||
#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG -0x0016 /**< ASN1 tag was of an unexpected value. */
|
||||
#define POLARSSL_ERR_ASN1_INVALID_LENGTH -0x0018 /**< Error when trying to determine the length or invalid length. */
|
||||
#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH -0x001A /**< Actual length differs from expected length. */
|
||||
#define POLARSSL_ERR_ASN1_INVALID_DATA -0x001C /**< Data is invalid. (not used) */
|
||||
#define POLARSSL_ERR_ASN1_MALLOC_FAILED -0x001E /**< Memory allocation failed */
|
||||
#define POLARSSL_ERR_ASN1_OUT_OF_DATA -0x0060 /**< Out of data when parsing an ASN1 data structure. */
|
||||
#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG -0x0062 /**< ASN1 tag was of an unexpected value. */
|
||||
#define POLARSSL_ERR_ASN1_INVALID_LENGTH -0x0064 /**< Error when trying to determine the length or invalid length. */
|
||||
#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH -0x0066 /**< Actual length differs from expected length. */
|
||||
#define POLARSSL_ERR_ASN1_INVALID_DATA -0x0068 /**< Data is invalid. (not used) */
|
||||
#define POLARSSL_ERR_ASN1_MALLOC_FAILED -0x006A /**< Memory allocation failed */
|
||||
/* \} name */
|
||||
|
||||
/**
|
||||
|
|
|
|||
46
include/polarssl/asn1write.h
Normal file
46
include/polarssl/asn1write.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* \file asn1write.h
|
||||
*
|
||||
* \brief ASN.1 buffer writing functionality
|
||||
*
|
||||
* Copyright (C) 2006-2012, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#ifndef POLARSSL_ASN1_WRITE_H
|
||||
#define POLARSSL_ASN1_WRITE_H
|
||||
|
||||
#include "asn1.h"
|
||||
|
||||
#define POLARSSL_ERR_ASN1_BUF_TOO_SMALL -0x006C /**< Buffer too small when writing ASN.1 data structure. */
|
||||
|
||||
#define ASN1_CHK_ADD(g, f) if( ( ret = f ) < 0 ) return( ret ); else g += ret
|
||||
|
||||
int asn1_write_len( unsigned char **p, unsigned char *start, size_t len );
|
||||
int asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag );
|
||||
int asn1_write_mpi( unsigned char **p, unsigned char *start, mpi *X );
|
||||
int asn1_write_null( unsigned char **p, unsigned char *start );
|
||||
int asn1_write_oid( unsigned char **p, unsigned char *start, char *oid );
|
||||
int asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start, char *algorithm_oid );
|
||||
int asn1_write_int( unsigned char **p, unsigned char *start, int val );
|
||||
int asn1_write_printable_string( unsigned char **p, unsigned char *start,
|
||||
char *text );
|
||||
|
||||
#endif /* POLARSSL_ASN1_WRITE_H */
|
||||
|
|
@ -288,6 +288,15 @@
|
|||
*/
|
||||
#define POLARSSL_ASN1_PARSE_C
|
||||
|
||||
/**
|
||||
* \def POLARSSL_ASN1_WRITE_C
|
||||
*
|
||||
* Enable the generic ASN1 writer.
|
||||
*
|
||||
* Module: library/asn1write.c
|
||||
*/
|
||||
#define POLARSSL_ASN1_WRITE_C
|
||||
|
||||
/**
|
||||
* \def POLARSSL_BASE64_C
|
||||
*
|
||||
|
|
@ -697,6 +706,19 @@
|
|||
*/
|
||||
#define POLARSSL_X509_PARSE_C
|
||||
|
||||
/**
|
||||
* \def POLARSSL_X509_WRITE_C
|
||||
*
|
||||
* Enable X.509 buffer writing.
|
||||
*
|
||||
* Module: library/x509write.c
|
||||
*
|
||||
* Requires: POLARSSL_BIGNUM_C, POLARSSL_RSA_C
|
||||
*
|
||||
* This module is required for X.509 certificate request writing.
|
||||
*/
|
||||
#define POLARSSL_X509_WRITE_C
|
||||
|
||||
/**
|
||||
* \def POLARSSL_XTEA_C
|
||||
*
|
||||
|
|
|
|||
|
|
@ -49,16 +49,16 @@
|
|||
*
|
||||
* Module Nr Codes assigned
|
||||
* MPI 7 0x0002-0x0010
|
||||
* ASN1 6 0x0014-0x001E
|
||||
* AES 2 0x0020-0x0022
|
||||
* CAMELLIA 2 0x0024-0x0026
|
||||
* XTEA 1 0x0028-0x0028
|
||||
* BASE64 2 0x002A-0x002C
|
||||
* PADLOCK 1 0x0030-0x0030
|
||||
* DES 1 0x0032-0x0032
|
||||
* NET 11 0x0040-0x0054
|
||||
* CTR_DBRG 3 0x0034-0x003A
|
||||
* ENTROPY 3 0x003C-0x0040
|
||||
* NET 11 0x0042-0x0056
|
||||
* ASN1 7 0x0060-0x006C
|
||||
* MD2 1 0x0070-0x0070
|
||||
* MD4 1 0x0072-0x0072
|
||||
* MD5 1 0x0074-0x0074
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#define POLARSSL_ERR_NET_UNKNOWN_HOST -0x0040 /**< Failed to get an IP address for the given hostname. */
|
||||
#define POLARSSL_ERR_NET_UNKNOWN_HOST -0x0056 /**< Failed to get an IP address for the given hostname. */
|
||||
#define POLARSSL_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */
|
||||
#define POLARSSL_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */
|
||||
#define POLARSSL_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */
|
||||
|
|
|
|||
|
|
@ -99,9 +99,15 @@
|
|||
|
||||
#define OID_X520 "\x55\x04"
|
||||
#define OID_CN OID_X520 "\x03"
|
||||
#define OID_COUNTRY OID_X520 "\x06"
|
||||
#define OID_LOCALITY OID_X520 "\x07"
|
||||
#define OID_STATE OID_X520 "\x08"
|
||||
#define OID_ORGANIZATION OID_X520 "\x0A"
|
||||
#define OID_ORG_UNIT OID_X520 "\x0B"
|
||||
|
||||
#define OID_PKCS1 "\x2A\x86\x48\x86\xF7\x0D\x01\x01"
|
||||
#define OID_PKCS1_RSA OID_PKCS1 "\x01"
|
||||
#define OID_PKCS1_SHA1 OID_PKCS1 "\x05"
|
||||
|
||||
#define OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D"
|
||||
|
||||
|
|
|
|||
46
include/polarssl/x509write.h
Normal file
46
include/polarssl/x509write.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* \file x509write.h
|
||||
*
|
||||
* \brief X509 buffer writing functionality
|
||||
*
|
||||
* Copyright (C) 2006-2012, Brainspark B.V.
|
||||
*
|
||||
* This file is part of PolarSSL (http://www.polarssl.org)
|
||||
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
#ifndef POLARSSL_X509_WRITE_H
|
||||
#define POLARSSL_X509_WRITE_H
|
||||
|
||||
#include "rsa.h"
|
||||
|
||||
typedef struct _x509_req_name
|
||||
{
|
||||
char oid[128];
|
||||
char name[128];
|
||||
|
||||
struct _x509_req_name *next;
|
||||
}
|
||||
x509_req_name;
|
||||
|
||||
int x509_write_pubkey_der( unsigned char *buf, size_t size, rsa_context *rsa );
|
||||
int x509_write_key_der( unsigned char *buf, size_t size, rsa_context *rsa );
|
||||
int x509_write_cert_req( unsigned char *buf, size_t size, rsa_context *rsa,
|
||||
x509_req_name *req_name );
|
||||
|
||||
#endif /* POLARSSL_X509_WRITE_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue