xmlsecurityengine/xmlseccrypto/src/xmlsecc_x509.cpp
changeset 15 9b1f1fe06753
parent 0 e35f40988205
child 16 d10d750052f0
equal deleted inserted replaced
3:e724ec518437 15:9b1f1fe06753
    87 static X509_CRL*	xmlSecSymbianCryptoX509CrlDerRead		(xmlSecByte* buf, 
    87 static X509_CRL*	xmlSecSymbianCryptoX509CrlDerRead		(xmlSecByte* buf, 
    88 								 xmlSecSize size);
    88 								 xmlSecSize size);
    89 static X509_CRL*	xmlSecSymbianCryptoX509CrlBase64DerRead	(xmlChar* buf);
    89 static X509_CRL*	xmlSecSymbianCryptoX509CrlBase64DerRead	(xmlChar* buf);
    90 static xmlChar*		xmlSecSymbianCryptoX509CrlBase64DerWrite	(X509_CRL* crl, 
    90 static xmlChar*		xmlSecSymbianCryptoX509CrlBase64DerWrite	(X509_CRL* crl, 
    91 								 int base64LineWrap);
    91 								 int base64LineWrap);
    92 static xmlChar*		xmlSecSymbianCryptoX509NameWrite		(X509_NAME* nm);
    92 //static xmlChar*		xmlSecSymbianCryptoX509NameWrite		(X509_NAME* nm);
    93 #ifdef XMLSEC_FUTURE_SUPPORT
    93 #ifdef XMLSEC_FUTURE_SUPPORT
    94 static xmlChar*		xmlSecSymbianCryptoASN1IntegerWrite		(ASN1_INTEGER *asni);
    94 static xmlChar*		xmlSecSymbianCryptoASN1IntegerWrite		(ASN1_INTEGER *asni);
    95 #endif //XMLSEC_FUTURE_SUPPORT
    95 #endif //XMLSEC_FUTURE_SUPPORT
    96 static xmlChar*		xmlSecSymbianCryptoX509SKIWrite		(X509* cert);
    96 static xmlChar*		xmlSecSymbianCryptoX509SKIWrite		(X509* cert);
    97 static void		xmlSecSymbianCryptoX509CertDebugDump		(X509* cert, 
    97 static void		xmlSecSymbianCryptoX509CertDebugDump		(X509* cert, 
   376  */
   376  */
   377 EXPORT_C
   377 EXPORT_C
   378 int 
   378 int 
   379 xmlSecSymbianCryptoKeyDataX509AdoptCert(xmlSecKeyDataPtr data, X509* cert) {
   379 xmlSecSymbianCryptoKeyDataX509AdoptCert(xmlSecKeyDataPtr data, X509* cert) {
   380     xmlSecSymbianCryptoX509DataCtxPtr ctx;
   380     xmlSecSymbianCryptoX509DataCtxPtr ctx;
   381     int ret;
   381     
   382     
   382     
   383     xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataX509Id), -1);
   383     xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataX509Id), -1);
   384     xmlSecAssert2(cert, -1);
   384     xmlSecAssert2(cert, -1);
   385 
   385 
   386     ctx = xmlSecSymbianCryptoX509DataGetCtx(data);
   386     ctx = xmlSecSymbianCryptoX509DataGetCtx(data);
   467  */
   467  */
   468 EXPORT_C
   468 EXPORT_C
   469 int 
   469 int 
   470 xmlSecSymbianCryptoKeyDataX509AdoptCrl(xmlSecKeyDataPtr data, X509_CRL* crl) {
   470 xmlSecSymbianCryptoKeyDataX509AdoptCrl(xmlSecKeyDataPtr data, X509_CRL* crl) {
   471     xmlSecSymbianCryptoX509DataCtxPtr ctx;
   471     xmlSecSymbianCryptoX509DataCtxPtr ctx;
   472     int ret;
   472    
   473     
   473     
   474     xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataX509Id), -1);
   474     xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataX509Id), -1);
   475     xmlSecAssert2(crl, -1);
   475     xmlSecAssert2(crl, -1);
   476 
   476 
   477     ctx = xmlSecSymbianCryptoX509DataGetCtx(data);
   477     ctx = xmlSecSymbianCryptoX509DataGetCtx(data);
  1679     }
  1679     }
  1680 
  1680 
  1681 	// do not use list first
  1681 	// do not use list first
  1682     //if((ctx->keyCert == NULL) && (ctx->certsList != NULL) && (xmlSecKeyGetValue(key) == NULL)) {
  1682     //if((ctx->keyCert == NULL) && (ctx->certsList != NULL) && (xmlSecKeyGetValue(key) == NULL)) {
  1683     if((ctx->keyCert) && (!xmlSecKeyGetValue(key)) ) {
  1683     if((ctx->keyCert) && (!xmlSecKeyGetValue(key)) ) {
  1684 	X509* cert;
  1684 	
  1685 	
  1685 	
  1686 	ret = xmlSecSymbianCryptoX509StoreKeyCertVerify(x509Store, ctx->keyCert);	
  1686 	ret = xmlSecSymbianCryptoX509StoreKeyCertVerify(x509Store, ctx->keyCert);	
  1687 	if(ret == 0) {
  1687 	if(ret == 0) {
  1688 	    xmlSecKeyDataPtr keyValue;
  1688 	    xmlSecKeyDataPtr keyValue;
  1689 	    /*
  1689 	    /*
  1797 #else /* WIN32 */
  1797 #else /* WIN32 */
  1798 /* Absolutely not the best way but it's the only ANSI compatible way I know.
  1798 /* Absolutely not the best way but it's the only ANSI compatible way I know.
  1799  * If you system has a native struct tm --> GMT time_t conversion function
  1799  * If you system has a native struct tm --> GMT time_t conversion function
  1800  * (like timegm) use it instead.
  1800  * (like timegm) use it instead.
  1801  */
  1801  */
       
  1802  /*
  1802 static time_t 
  1803 static time_t 
  1803 my_timegm(struct tm *t) {  
  1804 my_timegm(struct tm *t) {  
  1804     time_t tl, tb;  
  1805     time_t tl, tb;  
  1805     struct tm *tg;  
  1806     struct tm *tg;  
  1806 
  1807 
  1826     }  
  1827     }  
  1827     return (tl - (tb - tl)); 
  1828     return (tl - (tb - tl)); 
  1828 }
  1829 }
  1829 
  1830 
  1830 #define timegm(tm) my_timegm(tm)
  1831 #define timegm(tm) my_timegm(tm)
       
  1832 */
  1831 #endif /* WIN32 */
  1833 #endif /* WIN32 */
  1832 #endif /* HAVE_TIMEGM */
  1834 #endif /* HAVE_TIMEGM */
  1833 
  1835 
  1834 #ifdef XMLSEC_FUTURE_SUPPORT
  1836 #ifdef XMLSEC_FUTURE_SUPPORT
  1835 static int
  1837 static int
  2014 }
  2016 }
  2015 
  2017 
  2016 static xmlChar*
  2018 static xmlChar*
  2017 xmlSecSymbianCryptoX509CertBase64DerWrite(X509* cert, int base64LineWrap) {
  2019 xmlSecSymbianCryptoX509CertBase64DerWrite(X509* cert, int base64LineWrap) {
  2018     xmlChar *res = NULL;
  2020     xmlChar *res = NULL;
  2019     xmlSecByte *p = NULL;
  2021     
  2020     long size;
  2022    
  2021 
  2023 
  2022     xmlSecAssert2(cert, NULL);
  2024     xmlSecAssert2(cert, NULL);
  2023     
  2025     
  2024     res = xmlSecBase64Encode((const xmlSecByte*)cert->der, cert->derlen, base64LineWrap);
  2026     res = xmlSecBase64Encode((const xmlSecByte*)cert->der, cert->derlen, base64LineWrap);
  2025     if(!res) {
  2027     if(!res) {
  2065 }
  2067 }
  2066 
  2068 
  2067 static xmlChar*
  2069 static xmlChar*
  2068 xmlSecSymbianCryptoX509CrlBase64DerWrite(X509_CRL* crl, int base64LineWrap) {
  2070 xmlSecSymbianCryptoX509CrlBase64DerWrite(X509_CRL* crl, int base64LineWrap) {
  2069     xmlChar *res = NULL;
  2071     xmlChar *res = NULL;
  2070     xmlSecByte *p = NULL;
  2072     
  2071     long size;
  2073     
  2072 
  2074 
  2073     xmlSecAssert2(crl, NULL);
  2075     xmlSecAssert2(crl, NULL);
  2074 #ifdef XMLSEC_FUTURE_SUPPORT	
  2076 #ifdef XMLSEC_FUTURE_SUPPORT	
  2075     mem = BIO_new(BIO_s_mem());
  2077     mem = BIO_new(BIO_s_mem());
  2076     if(!mem) {
  2078     if(!mem) {
  2110     BIO_free_all(mem);    
  2112     BIO_free_all(mem);    
  2111     
  2113     
  2112 #endif    
  2114 #endif    
  2113     return(res);
  2115     return(res);
  2114 }
  2116 }
  2115 
  2117 /*
  2116 static xmlChar*
  2118 static xmlChar*
  2117 xmlSecSymbianCryptoX509NameWrite(X509_NAME* nm) {
  2119 xmlSecSymbianCryptoX509NameWrite(X509_NAME* nm) {
  2118     xmlChar *res = NULL;
  2120     xmlChar *res = NULL;
  2119     long size;
  2121     long size;
  2120 
  2122 
  2159 
  2161 
  2160     BIO_free_all(mem);
  2162     BIO_free_all(mem);
  2161 #endif    
  2163 #endif    
  2162     return(res);
  2164     return(res);
  2163 }
  2165 }
  2164 
  2166 */
  2165 #ifdef XMLSEC_FUTURE_SUPPORT
  2167 #ifdef XMLSEC_FUTURE_SUPPORT
  2166 static xmlChar*
  2168 static xmlChar*
  2167 xmlSecSymbianCryptoASN1IntegerWrite(ASN1_INTEGER *asni) {
  2169 xmlSecSymbianCryptoASN1IntegerWrite(ASN1_INTEGER *asni) {
  2168     xmlChar *res = NULL;
  2170     xmlChar *res = NULL;
  2169     BIGNUM *bn;
  2171     BIGNUM *bn;
  2214 #endif	//XMLSEC_FUTURE_SUPPORT 
  2216 #endif	//XMLSEC_FUTURE_SUPPORT 
  2215 
  2217 
  2216 static xmlChar*
  2218 static xmlChar*
  2217 xmlSecSymbianCryptoX509SKIWrite(X509* cert) {
  2219 xmlSecSymbianCryptoX509SKIWrite(X509* cert) {
  2218     xmlChar *res = NULL;
  2220     xmlChar *res = NULL;
  2219     int index;
  2221    
  2220 #ifdef XMLSEC_FUTURE_SUPPORT    
  2222 #ifdef XMLSEC_FUTURE_SUPPORT    
  2221     X509_EXTENSION *ext;
  2223     X509_EXTENSION *ext;
  2222     ASN1_OCTET_STRING *keyId;
  2224     ASN1_OCTET_STRING *keyId;
  2223 
  2225 
  2224     xmlSecAssert2(cert, NULL);
  2226     xmlSecAssert2(cert, NULL);
  2269     return(res);
  2271     return(res);
  2270 }
  2272 }
  2271 
  2273 
  2272 static void 
  2274 static void 
  2273 xmlSecSymbianCryptoX509CertDebugDump(X509* cert, FILE* output) {
  2275 xmlSecSymbianCryptoX509CertDebugDump(X509* cert, FILE* output) {
  2274     char buf[1024];
  2276     
  2275 #ifdef XMLSEC_FUTURE_SUPPORT    
  2277 #ifdef XMLSEC_FUTURE_SUPPORT    
  2276     BIGNUM *bn = NULL;
  2278     BIGNUM *bn = NULL;
  2277 
  2279 
  2278     xmlSecAssert(cert);
  2280     xmlSecAssert(cert);
  2279     xmlSecAssert(output);
  2281     xmlSecAssert(output);
  2295 }
  2297 }
  2296 
  2298 
  2297 
  2299 
  2298 static void 
  2300 static void 
  2299 xmlSecSymbianCryptoX509CertDebugXmlDump(X509* cert, FILE* output) {
  2301 xmlSecSymbianCryptoX509CertDebugXmlDump(X509* cert, FILE* output) {
  2300     char buf[1024];
  2302   
  2301 #ifdef XMLSEC_FUTURE_SUPPORT    
  2303 #ifdef XMLSEC_FUTURE_SUPPORT    
  2302     BIGNUM *bn = NULL;
  2304     BIGNUM *bn = NULL;
  2303 
  2305 
  2304     xmlSecAssert(cert);
  2306     xmlSecAssert(cert);
  2305     xmlSecAssert(output);
  2307     xmlSecAssert(output);