xmlsecurityengine/xmlseccrypto/inc/xmlsecc_x509wrapper.h
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Methods that allows to process X509 certificates.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /* A wrapper for x509.h in openssl */
       
    20 
       
    21 #ifndef __XMLSEC_SYMBIANCRYPTO_X509_WRAPPER_H__
       
    22 #define __XMLSEC_SYMBIANCRYPTO_X509_WRAPPER_H__    
       
    23 
       
    24 
       
    25 #ifdef __cplusplus
       
    26 extern "C" {
       
    27 #endif /* __cplusplus */ 
       
    28 #include "xmlsecc_config.h"
       
    29 
       
    30 #ifndef XMLSEC_NO_X509
       
    31 
       
    32 #include "xmlsecc_evpwrapper.h"
       
    33 
       
    34 /*
       
    35 struct ScX509PubKeySt;
       
    36 typedef struct ScX509PubKeySt X509_PUBKEY;
       
    37 typedef struct ScX509St
       
    38 {
       
    39 	char*			der;		// Certificate in ASN.1 DER format 
       
    40 	unsigned int	derlen;
       
    41 	X509_PUBKEY		*extractedPublicKey;	
       
    42 
       
    43 } X509;
       
    44 */
       
    45 
       
    46 typedef struct ScX509CrlSt
       
    47 {
       
    48 	/* actual signature */
       
    49 	int 		dummy;
       
    50 } X509_CRL; /* X509_CRL */
       
    51 
       
    52 
       
    53 typedef struct ScX509NameSt
       
    54 {
       
    55 	char *bytes;
       
    56 	unsigned long hash; /* Keep the hash around for lookups */
       
    57 } X509_NAME; /* X509_NAME */
       
    58 
       
    59 /*
       
    60 typedef struct ScX509Store
       
    61 {
       
    62 	int 		dummy;
       
    63 } X509_STORE; // X509_STORE 
       
    64 */
       
    65 struct ScX509Store;
       
    66 typedef struct ScX509Store X509_STORE;
       
    67 
       
    68 
       
    69 #define STACK_OF(type) type
       
    70 //#define STACK_OF(type)	struct stack_st_##type
       
    71 
       
    72 /** 
       
    73  * Free the X509 structure
       
    74  *
       
    75  * @param aCert X509 structure
       
    76  */
       
    77 void X509_free(X509* aCert);
       
    78 
       
    79 /** 
       
    80  * Free the X509_crl structure 
       
    81  *
       
    82  * @param aCrl X509_CRL structure
       
    83  */
       
    84 void X509_crl_free(X509_CRL* aCrl);
       
    85 
       
    86 /** 
       
    87  * Duplicate the X509 structure
       
    88  *
       
    89  * @param aCert X509 structure
       
    90  * @return reference to X509 duplicated structure 
       
    91  */
       
    92 X509* X509_dup(X509* aCert);
       
    93 
       
    94 /** 
       
    95  * Get the public key
       
    96  * 
       
    97  * @param aCert X509 structure
       
    98  * @return EVP_PKEY structure 
       
    99  */
       
   100 EVP_PKEY* X509_get_pubkey(X509* aCert);
       
   101 
       
   102 /** 
       
   103  * Read the certificate from DER format
       
   104  *
       
   105  * @param aBIO BIO structure
       
   106  * @return reference to X509 structure 
       
   107  */
       
   108 X509* d2i_X509_bio(BIO *aBio);
       
   109 
       
   110 /** 
       
   111  * Test the validity period from the certificate
       
   112  * 
       
   113  * @param aCert X509 structure
       
   114  *  @return validation period status
       
   115  */
       
   116 int X509_test_validityPeriod(X509* aCert);
       
   117 
       
   118 /************************************
       
   119  *                                          
       
   120  *   		X509 Store	        
       
   121  *                                                         
       
   122  ************************************/
       
   123 
       
   124 /**
       
   125  * Add a X509 certificate to the X509_STORE
       
   126  *
       
   127  * @param aCertStore X509_STORE structure
       
   128  * @param aCert X509 structure
       
   129  * @return 0 if correct adding
       
   130  * @return error in the other hand
       
   131  */
       
   132 int X509_STORE_add_cert(X509_STORE *aCertStore, X509 *aCert);
       
   133 
       
   134 /**
       
   135  * Initialize the X509_STORE structure
       
   136  * 
       
   137  * @return reference to X509_STORE structure 
       
   138  */
       
   139 X509_STORE *X509_STORE_new(void );
       
   140 
       
   141 /**
       
   142  * Initialize the SymbianCertChain
       
   143  *
       
   144  * @param aCertStore X509_STORE structure
       
   145  * @param aCert STACK_OF(X509) structure
       
   146  * @return 0 if correct initializing
       
   147  * @return error in the other hand
       
   148  */
       
   149 int X509_STORE_certchain_init (X509_STORE *aCertStore, STACK_OF(X509) *aCert);
       
   150 
       
   151 /**
       
   152  * Initialize the SymbianCertChain with cert from SymbianCertStore
       
   153  *
       
   154  * @param aCertStore X509_STORE structure
       
   155  * @param aCert STACK_OF(X509) structure
       
   156  * @return 0 if correct initializing
       
   157  * @return error in the other hand
       
   158  */
       
   159 int X509_STORE_certchain_init_fromCertStore (X509_STORE *aCertStore, STACK_OF(X509) *aCert);
       
   160 
       
   161 /**
       
   162  * Validate the certificates 
       
   163  *
       
   164  * @param aCertStore X509_STORE structure
       
   165  * @return 0 if correct initializing
       
   166  * @return error in the other hand
       
   167  */
       
   168 int X509_STORE_certchain_validate (X509_STORE *aCertStore);
       
   169 
       
   170 /** 
       
   171  * Get the validation result: 1 - success; 0 - failed 
       
   172  *
       
   173  * @param aCertStore X509_STORE structure
       
   174  * @return 1 if validation succeed
       
   175  * @return 0 if validation failed
       
   176  */
       
   177 int X509_STORE_certchain_getValidateResult (X509_STORE *aCertStore);
       
   178 
       
   179 /** 
       
   180  * Free the X509_STORE structure 
       
   181  *
       
   182  * @param aCertStore X509_STORE structure
       
   183  */
       
   184 void X509_STORE_free(X509_STORE *aCertStore);
       
   185 
       
   186 #endif /* XMLSEC_NO_X509 */
       
   187 
       
   188 #ifdef __cplusplus
       
   189 }
       
   190 #endif /* __cplusplus */
       
   191 
       
   192 #endif /* __SYMBIANCRYPTO_X509_WRAPPER_H__ */
       
   193 
       
   194 #define __SYMBIANCRYPTO_X509_WRAPPER_H__