More get0 et al. changes. Also provide fgrep targets in CHANGES
[openssl.git] / crypto / x509 / x509_vfy.c
index 2668bd19594169d6501e76c35a13f30a5de5b5e9..4fdff54124c3ace538d65e5259a6a7357b9eb94d 100644 (file)
@@ -76,7 +76,7 @@ static int check_trust(X509_STORE_CTX *ctx);
 static int internal_verify(X509_STORE_CTX *ctx);
 const char *X509_version="X.509" OPENSSL_VERSION_PTEXT;
 
-static STACK *x509_store_ctx_method=NULL;
+static STACK_OF(CRYPTO_EX_DATA_FUNCS) *x509_store_ctx_method=NULL;
 static int x509_store_ctx_num=0;
 #if 0
 static int x509_store_num=1;
@@ -536,7 +536,7 @@ int X509_cmp_current_time(ASN1_UTCTIME *ctm)
        atm.length=sizeof(buff2);
        atm.data=(unsigned char *)buff2;
 
-       X509_gmtime_adj(&atm,-offset);
+       X509_gmtime_adj(&atm,-offset*60);
 
        i=(buff1[0]-'0')*10+(buff1[1]-'0');
        if (i < 50) i+=100; /* cf. RFC 2459 */
@@ -622,13 +622,13 @@ int X509_STORE_add_cert(X509_STORE *ctx, X509 *x)
 
        X509_OBJECT_up_ref_count(obj);
 
-       r=(X509_OBJECT *)lh_insert(ctx->certs,(char *)obj);
+       r=(X509_OBJECT *)lh_insert(ctx->certs,obj);
        if (r != NULL)
                { /* oops, put it back */
-               lh_delete(ctx->certs,(char *)obj);
+               lh_delete(ctx->certs,obj);
                X509_OBJECT_free_contents(obj);
                Free(obj);
-               lh_insert(ctx->certs,(char *)r);
+               lh_insert(ctx->certs,r);
                X509err(X509_F_X509_STORE_ADD_CERT,X509_R_CERT_ALREADY_IN_HASH_TABLE);
                ret=0;
                }
@@ -657,13 +657,13 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
 
        X509_OBJECT_up_ref_count(obj);
 
-       r=(X509_OBJECT *)lh_insert(ctx->certs,(char *)obj);
+       r=(X509_OBJECT *)lh_insert(ctx->certs,obj);
        if (r != NULL)
                { /* oops, put it back */
-               lh_delete(ctx->certs,(char *)obj);
+               lh_delete(ctx->certs,obj);
                X509_OBJECT_free_contents(obj);
                Free(obj);
-               lh_insert(ctx->certs,(char *)r);
+               lh_insert(ctx->certs,r);
                X509err(X509_F_X509_STORE_ADD_CRL,X509_R_CERT_ALREADY_IN_HASH_TABLE);
                ret=0;
                }
@@ -673,8 +673,8 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
        return(ret);    
        }
 
-int X509_STORE_CTX_get_ex_new_index(long argl, char *argp, int (*new_func)(),
-            int (*dup_func)(), void (*free_func)())
+int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
+            CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
         {
         x509_store_ctx_num++;
         return(CRYPTO_get_ex_new_index(x509_store_ctx_num-1,
@@ -717,6 +717,19 @@ STACK_OF(X509) *X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx)
        return(ctx->chain);
        }
 
+STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
+       {
+       int i;
+       X509 *x;
+       STACK_OF(X509) *chain;
+       if(!ctx->chain || !(chain = sk_X509_dup(ctx->chain))) return NULL;
+       for(i = 0; i < sk_X509_num(chain); i++) {
+               x = sk_X509_value(chain, i);
+               CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
+       }
+       return(chain);
+       }
+
 void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x)
        {
        ctx->cert=x;
@@ -764,7 +777,7 @@ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
                /* If trust not set then get from purpose default */
                if(!trust) {
                        X509_PURPOSE *ptmp;
-                       ptmp = X509_PURPOSE_iget(idx);
+                       ptmp = X509_PURPOSE_get0(idx);
                        trust = ptmp->trust;
                }
        }