84 /* reserved for the future */ |
84 /* reserved for the future */ |
85 NULL, /* void* reserved0; */ |
85 NULL, /* void* reserved0; */ |
86 NULL, /* void* reserved1; */ |
86 NULL, /* void* reserved1; */ |
87 }; |
87 }; |
88 |
88 |
89 static int xmlSecSymbianCryptoX509VerifyCrl (X509_STORE* xst, |
89 /*static int xmlSecSymbianCryptoX509VerifyCrl (X509_STORE* xst, |
90 X509_CRL *crl ); |
90 X509_CRL *crl );*/ |
91 static X509* xmlSecSymbianCryptoX509FindCert (STACK_OF(X509) *certs, |
91 static X509* xmlSecSymbianCryptoX509FindCert (STACK_OF(X509) *certs, |
92 xmlChar *subjectName, |
92 xmlChar *subjectName, |
93 xmlChar *issuerName, |
93 xmlChar *issuerName, |
94 xmlChar *issuerSerial, |
94 xmlChar *issuerSerial, |
95 xmlChar *ski); |
95 xmlChar *ski); |
96 static X509* xmlSecSymbianCryptoX509FindNextChainCert (STACK_OF(X509) *chain, |
96 /*static X509* xmlSecSymbianCryptoX509FindNextChainCert (STACK_OF(X509) *chain, |
97 X509 *cert); |
97 X509 *cert); |
98 static int xmlSecSymbianCryptoX509VerifyCertAgainstCrls (STACK_OF(X509_CRL) *crls, |
98 static int xmlSecSymbianCryptoX509VerifyCertAgainstCrls (STACK_OF(X509_CRL) *crls, |
99 X509* cert); |
99 X509* cert); |
100 static X509_NAME* xmlSecSymbianCryptoX509NameRead (xmlSecByte *str, |
100 static X509_NAME* xmlSecSymbianCryptoX509NameRead (xmlSecByte *str, |
101 int len); |
101 int len); |
257 EXPORT_C |
257 EXPORT_C |
258 X509* |
258 X509* |
259 xmlSecSymbianCryptoX509StoreVerify(xmlSecKeyDataStorePtr store, XMLSEC_STACK_OF_X509* certs, |
259 xmlSecSymbianCryptoX509StoreVerify(xmlSecKeyDataStorePtr store, XMLSEC_STACK_OF_X509* certs, |
260 XMLSEC_STACK_OF_X509_CRL* crls, xmlSecKeyInfoCtx* keyInfoCtx) { |
260 XMLSEC_STACK_OF_X509_CRL* crls, xmlSecKeyInfoCtx* keyInfoCtx) { |
261 xmlSecSymbianCryptoX509StoreCtxPtr ctx; |
261 xmlSecSymbianCryptoX509StoreCtxPtr ctx; |
262 STACK_OF(X509)* certs2 = NULL; |
262 |
263 X509* res = NULL; |
263 X509* res = NULL; |
264 X509* cert = NULL; |
264 X509* cert = NULL; |
265 X509 *err_cert = NULL; |
265 |
266 char buf[256]; |
266 |
267 int err = 0, depth; |
267 int err = 0; |
268 int i; |
268 |
269 int ret; |
269 int ret; |
270 |
270 |
271 xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecSymbianCryptoX509StoreId), NULL); |
271 xmlSecAssert2(xmlSecKeyDataStoreCheckId(store, xmlSecSymbianCryptoX509StoreId), NULL); |
272 xmlSecAssert2(certs, NULL); |
272 xmlSecAssert2(certs, NULL); |
273 xmlSecAssert2(keyInfoCtx, NULL); |
273 xmlSecAssert2(keyInfoCtx, NULL); |
792 } |
792 } |
793 X509_STORE_CTX_cleanup (&xsc); |
793 X509_STORE_CTX_cleanup (&xsc); |
794 #endif //XMLSEC_FUTURE_SUPPORT |
794 #endif //XMLSEC_FUTURE_SUPPORT |
795 return((ret == 1) ? 1 : 0); |
795 return((ret == 1) ? 1 : 0); |
796 } |
796 } |
|
797 */ |
797 |
798 |
798 /** |
799 /** |
799 * xmlSecSymbianCryptoX509FindCert: |
800 * xmlSecSymbianCryptoX509FindCert: |
800 */ |
801 */ |
801 static X509* |
802 static X509* |
802 xmlSecSymbianCryptoX509FindCert(STACK_OF(X509) *certs, xmlChar *subjectName, |
803 xmlSecSymbianCryptoX509FindCert(STACK_OF(X509) *certs, xmlChar *subjectName, |
803 xmlChar *issuerName, xmlChar *issuerSerial, |
804 xmlChar *issuerName, xmlChar *issuerSerial, |
804 xmlChar *ski) { |
805 xmlChar *ski) { |
805 X509 *cert = NULL; |
806 |
806 int i; |
807 |
807 |
808 |
808 xmlSecAssert2(certs, NULL); |
809 xmlSecAssert2(certs, NULL); |
809 #ifdef XMLSEC_FUTURE_SUPPORT |
810 #ifdef XMLSEC_FUTURE_SUPPORT |
810 /* may be this is not the fastest way to search certs */ |
811 /* may be this is not the fastest way to search certs */ |
811 if(subjectName) { |
812 if(subjectName) { |
938 } |
939 } |
939 |
940 |
940 /** |
941 /** |
941 * xmlSecSymbianCryptoX509FindNextChainCert: |
942 * xmlSecSymbianCryptoX509FindNextChainCert: |
942 */ |
943 */ |
|
944 /* |
943 static X509* |
945 static X509* |
944 xmlSecSymbianCryptoX509FindNextChainCert(STACK_OF(X509) *chain, X509 *cert) { |
946 xmlSecSymbianCryptoX509FindNextChainCert(STACK_OF(X509) *chain, X509 *cert) { |
945 unsigned long certSubjHash; |
947 |
946 int i; |
948 |
947 |
949 |
948 xmlSecAssert2(chain, NULL); |
950 xmlSecAssert2(chain, NULL); |
949 xmlSecAssert2(cert, NULL); |
951 xmlSecAssert2(cert, NULL); |
950 /* |
952 |
951 certSubjHash = X509_subject_name_hash(cert); |
953 certSubjHash = X509_subject_name_hash(cert); |
952 for(i = 0; i < sk_X509_num(chain); ++i) { |
954 for(i = 0; i < sk_X509_num(chain); ++i) { |
953 if((sk_X509_value(chain, i) != cert) && |
955 if((sk_X509_value(chain, i) != cert) && |
954 (X509_issuer_name_hash(sk_X509_value(chain, i)) == certSubjHash)) { |
956 (X509_issuer_name_hash(sk_X509_value(chain, i)) == certSubjHash)) { |
955 |
957 |
956 return(sk_X509_value(chain, i)); |
958 return(sk_X509_value(chain, i)); |
957 } |
959 } |
958 } |
960 } |
959 */ |
961 |
960 return(NULL); |
962 return(NULL); |
961 } |
963 } |
962 |
964 */ |
963 /** |
965 /** |
964 * xmlSecSymbianCryptoX509VerifyCertAgainstCrls: |
966 * xmlSecSymbianCryptoX509VerifyCertAgainstCrls: |
965 */ |
967 */ |
|
968 /* |
966 static int |
969 static int |
967 xmlSecSymbianCryptoX509VerifyCertAgainstCrls(STACK_OF(X509_CRL) *crls, X509* cert) { |
970 xmlSecSymbianCryptoX509VerifyCertAgainstCrls(STACK_OF(X509_CRL) *crls, X509* cert) { |
968 X509_NAME *issuer; |
971 |
969 X509_CRL *crl = NULL; |
972 |
970 #ifdef XMLSEC_FUTURE_SUPPORT |
973 #ifdef XMLSEC_FUTURE_SUPPORT |
971 X509_REVOKED *revoked; |
974 X509_REVOKED *revoked; |
972 int i, n; |
975 int i, n; |
973 int ret; |
976 int ret; |
974 |
977 |
975 xmlSecAssert2(crls, -1); |
978 xmlSecAssert2(crls, -1); |
976 xmlSecAssert2(cert, -1); |
979 xmlSecAssert2(cert, -1); |
977 |
980 |
978 /* |
981 |
979 * Try to retrieve a CRL corresponding to the issuer of |
982 * Try to retrieve a CRL corresponding to the issuer of |
980 * the current certificate |
983 * the current certificate |
981 */ |
984 |
982 n = sk_X509_CRL_num(crls); |
985 n = sk_X509_CRL_num(crls); |
983 for(i = 0; i < n; i++) { |
986 for(i = 0; i < n; i++) { |
984 crl = sk_X509_CRL_value(crls, i); |
987 crl = sk_X509_CRL_value(crls, i); |
985 issuer = X509_CRL_get_issuer(crl); |
988 issuer = X509_CRL_get_issuer(crl); |
986 if(xmlSecSymbianCryptoX509NamesCompare(X509_CRL_get_issuer(crl), issuer) == 0) { |
989 if(xmlSecSymbianCryptoX509NamesCompare(X509_CRL_get_issuer(crl), issuer) == 0) { |
987 break; |
990 break; |
988 } |
991 } |
989 } |
992 } |
990 if((i >= n) || (!crl)){ |
993 if((i >= n) || (!crl)){ |
991 /* no crls for this issuer */ |
994 // no crls for this issuer |
992 return(1); |
995 return(1); |
993 } |
996 } |
994 |
997 |
995 /* |
998 |
996 * Check date of CRL to make sure it's not expired |
999 // Check date of CRL to make sure it's not expired |
997 */ |
1000 |
998 ret = X509_cmp_current_time(X509_CRL_get_nextUpdate(crl)); |
1001 ret = X509_cmp_current_time(X509_CRL_get_nextUpdate(crl)); |
999 if (ret == 0) { |
1002 if (ret == 0) { |
1000 /* crl expired */ |
1003 //crl expired |
1001 return(1); |
1004 return(1); |
1002 } |
1005 } |
1003 |
1006 |
1004 /* |
1007 |
1005 * Check if the current certificate is revoked by this CRL |
1008 // Check if the current certificate is revoked by this CRL |
1006 */ |
1009 |
1007 n = sk_num(X509_CRL_get_REVOKED(crl)); |
1010 n = sk_num(X509_CRL_get_REVOKED(crl)); |
1008 for (i = 0; i < n; i++) { |
1011 for (i = 0; i < n; i++) { |
1009 revoked = (X509_REVOKED *)sk_value(X509_CRL_get_REVOKED(crl), i); |
1012 revoked = (X509_REVOKED *)sk_value(X509_CRL_get_REVOKED(crl), i); |
1010 if (ASN1_INTEGER_cmp(revoked->serialNumber, X509_get_serialNumber(cert)) == 0) { |
1013 if (ASN1_INTEGER_cmp(revoked->serialNumber, X509_get_serialNumber(cert)) == 0) { |
1011 xmlSecError(XMLSEC_ERRORS_HERE, |
1014 xmlSecError(XMLSEC_ERRORS_HERE, |
1142 } |
1147 } |
1143 #endif //XMLSEC_FUTURE_SUPPORT |
1148 #endif //XMLSEC_FUTURE_SUPPORT |
1144 return(nm); |
1149 return(nm); |
1145 } |
1150 } |
1146 |
1151 |
1147 |
1152 */ |
1148 |
1153 |
1149 /** |
1154 /** |
1150 * xmlSecSymbianCryptoX509NameStringRead: |
1155 * xmlSecSymbianCryptoX509NameStringRead: |
1151 */ |
1156 */ |
|
1157 /* |
1152 static int |
1158 static int |
1153 xmlSecSymbianCryptoX509NameStringRead(xmlSecByte **str, int *strLen, |
1159 xmlSecSymbianCryptoX509NameStringRead(xmlSecByte **str, int *strLen, |
1154 xmlSecByte *res, int resLen, |
1160 xmlSecByte *res, int resLen, |
1155 xmlSecByte delim, int ingoreTrailingSpaces) { |
1161 xmlSecByte delim, int ingoreTrailingSpaces) { |
1156 xmlSecByte *p, *q, *nonSpace; |
1162 xmlSecByte *p, *q, *nonSpace; |
1264 XMLSEC_ERRORS_R_CRYPTO_FAILED, |
1274 XMLSEC_ERRORS_R_CRYPTO_FAILED, |
1265 XMLSEC_ERRORS_NO_MESSAGE); |
1275 XMLSEC_ERRORS_NO_MESSAGE); |
1266 return(1); |
1276 return(1); |
1267 } |
1277 } |
1268 |
1278 |
1269 /* sort both */ |
1279 //sort both |
1270 sk_X509_NAME_ENTRY_set_cmp_func(a1->entries, xmlSecSymbianCryptoX509_NAME_ENTRY_cmp); |
1280 sk_X509_NAME_ENTRY_set_cmp_func(a1->entries, xmlSecSymbianCryptoX509_NAME_ENTRY_cmp); |
1271 sk_X509_NAME_ENTRY_sort(a1->entries); |
1281 sk_X509_NAME_ENTRY_sort(a1->entries); |
1272 sk_X509_NAME_ENTRY_set_cmp_func(b1->entries, xmlSecSymbianCryptoX509_NAME_ENTRY_cmp); |
1282 sk_X509_NAME_ENTRY_set_cmp_func(b1->entries, xmlSecSymbianCryptoX509_NAME_ENTRY_cmp); |
1273 sk_X509_NAME_ENTRY_sort(b1->entries); |
1283 sk_X509_NAME_ENTRY_sort(b1->entries); |
1274 |
1284 |
1275 /* actually compare */ |
1285 //actually compare |
1276 ret = xmlSecSymbianCryptoX509_NAME_cmp(a1, b1); |
1286 ret = xmlSecSymbianCryptoX509_NAME_cmp(a1, b1); |
1277 |
1287 |
1278 /* cleanup */ |
1288 //cleanup |
1279 X509_NAME_free(a1); |
1289 X509_NAME_free(a1); |
1280 X509_NAME_free(b1); |
1290 X509_NAME_free(b1); |
1281 #endif //XMLSEC_FUTURE_SUPPORT |
1291 #endif //XMLSEC_FUTURE_SUPPORT |
1282 return(ret); |
1292 return(ret); |
1283 } |
1293 } |
1284 |
1294 */ |
1285 |
1295 |
1286 /** |
1296 /** |
1287 * xmlSecSymbianCryptoX509_NAME_ENTRY_cmp: |
1297 * xmlSecSymbianCryptoX509_NAME_ENTRY_cmp: |
1288 */ |
1298 */ |
1289 #ifdef XMLSEC_FUTURE_SUPPORT |
1299 #ifdef XMLSEC_FUTURE_SUPPORT |