add test case to makefiles
[openssl.git] / crypto / x509v3 / v3_genn.c
index 363f2d32d5f72efec67f96aa41121c8ea204061b..b6283573013e07eca9294c3166e899ee519a6bf6 100644 (file)
@@ -1,9 +1,9 @@
 /* v3_genn.c */
-/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL
+/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 1999.
  */
 /* ====================================================================
- * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2008 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -158,3 +158,95 @@ int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b)
        result = ASN1_TYPE_cmp(a->value, b->value);
        return result;
        }
+
+void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value)
+       {
+       switch(type)
+               {
+       case GEN_X400:
+       case GEN_EDIPARTY:
+               a->d.other = value;
+               break;
+
+       case GEN_OTHERNAME:
+               a->d.otherName = value;
+               break;
+
+       case GEN_EMAIL:
+       case GEN_DNS:
+       case GEN_URI:
+               a->d.ia5 = value;
+               break;
+
+       case GEN_DIRNAME:
+               a->d.dirn = value;
+               break;
+
+       case GEN_IPADD:
+               a->d.ip = value;
+               break;
+       
+       case GEN_RID:
+               a->d.rid = value;
+               break;
+               }
+       a->type = type;
+       }
+
+void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype)
+       {
+       if (ptype)
+               *ptype = a->type;
+       switch(a->type)
+               {
+       case GEN_X400:
+       case GEN_EDIPARTY:
+               return a->d.other;
+
+       case GEN_OTHERNAME:
+               return a->d.otherName;
+
+       case GEN_EMAIL:
+       case GEN_DNS:
+       case GEN_URI:
+               return a->d.ia5;
+
+       case GEN_DIRNAME:
+               return a->d.dirn;
+
+       case GEN_IPADD:
+               return a->d.ip;
+       
+       case GEN_RID:
+               return a->d.rid;
+
+       default:
+               return NULL;
+               }
+       }
+
+int GENERAL_NAME_set0_othername(GENERAL_NAME *gen,
+                               ASN1_OBJECT *oid, ASN1_TYPE *value)
+       {
+       OTHERNAME *oth;
+       oth = OTHERNAME_new();
+       if (!oth)
+               return 0;
+       oth->type_id = oid;
+       oth->value = value;
+       GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth);
+       return 1;
+       }
+
+int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, 
+                               ASN1_OBJECT **poid, ASN1_TYPE **pvalue)
+       {
+       if (gen->type != GEN_OTHERNAME)
+               return 0;
+       if (poid)
+               *poid = gen->d.otherName->type_id;
+       if (pvalue)
+               *pvalue = gen->d.otherName->value;
+       return 1;
+       }
+