Index: libabac/abac.c
===================================================================
--- libabac/abac.c	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/abac.c	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -6,4 +6,5 @@
 
 #include "abac.h"
+#include "abac_list.h"
 #include "abac_graph.h"
 #include "abac_util.h"
@@ -116,5 +117,5 @@
 int abac_context_load_attribute_chunk(abac_context_t *ctx, abac_chunk_t cert_chunk) {
     int ret, add_ret;
-    abac_list_t  *cred_list=NULL;
+    abac_list_t  *cred_list=abac_list_new(); // could be more than 1
     abac_credential_t *cred;
 
Index: libabac/abac.h
===================================================================
--- libabac/abac.h	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/abac.h	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -4,5 +4,4 @@
 #include <time.h>  // for struct tm 
 #include <stdio.h> // for FILE
-#include "abac_list.h"
 
 typedef struct _abac_context_t abac_context_t;
@@ -12,4 +11,6 @@
 typedef struct _abac_id_t abac_id_t;
 typedef struct _abac_attribute_t abac_attribute_t;
+
+typedef struct _abac_list_t ABAC_LIST_T;
 
 typedef struct _abac_chunk_t {
@@ -191,8 +192,9 @@
 // write the cert to a file. returns 0 if the cert hasn't been baked
 int abac_attribute_write(abac_attribute_t *attr, FILE *out);
+int abac_attribute_write_file(abac_attribute_t *attr, const char *fname);
 
 // get chunked cert
 // returns 0 if the cert isn't baked
-int abac_attribute_cert_chunk(abac_attribute_t *, abac_chunk_t *);
+abac_chunk_t abac_attribute_cert_chunk(abac_attribute_t *);
 
 // destroy the cert
@@ -200,8 +202,8 @@
 
 // load a list of attr cert from file (aborts on fail)
-abac_list_t *abac_attribute_certs_from_file(char *);
+ABAC_LIST_T *abac_attribute_certs_from_file(char *);
 
 // load a list of attr cert from chunk (aborts on fail)
-abac_list_t *abac_attribute_certs_from_chunk(abac_chunk_t);
+ABAC_LIST_T *abac_attribute_certs_from_chunk(abac_chunk_t);
 
 // get the attribute role string
Index: libabac/abac.hh
===================================================================
--- libabac/abac.hh	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/abac.hh	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -11,4 +11,7 @@
         #include "abac.h"
     }
+
+    class Attribute;
+    class ID;
 
     class Role {
@@ -145,5 +148,5 @@
             void load_privkey(char *filename) {
                 int ret = abac_id_privkey_from_file(m_id, filename);
-                if (!ret)
+                if (ret != ABAC_SUCCESS)
                     throw std::invalid_argument("Could not load private key");
             }
@@ -151,7 +154,7 @@
             char *keyid() { return abac_id_keyid(m_id); }
             char *cert_filename() { return abac_id_cert_filename(m_id); }
-            void write_cert(std::FILE *out) { abac_id_write_cert(m_id, out); }
+            void write_cert(FILE *out) { abac_id_write_cert(m_id, out); }
             void write_cert(const std::string &name) {
-                std::FILE *out = fopen(name.c_str(), "w");
+                FILE *out = fopen(name.c_str(), "w");
                 if (out == NULL)
                     throw std::invalid_argument("Could not open cert file for writing");
@@ -160,17 +163,17 @@
             }
             // Simplifies access from swig
-            void write_cert(const char *n) {
+            void write_cert_file(const char *n) {
                 write_cert(std::string(n));
             }
             char *privkey_filename() { return abac_id_privkey_filename(m_id); }
 
-            // write the private ket
+            // write the private key
             // throws a std::logic_error if no private key is loaded
-            void write_privkey(std::FILE *out) {
+            void write_privkey(FILE *out) {
                 int ret = abac_id_write_privkey(m_id, out);
-                if (!ret) throw std::logic_error("No private key loaded");
+                if (ret!=ABAC_SUCCESS) throw std::logic_error("No private key loaded");
             }
             void write_privkey(const std::string &name) {
-                std::FILE *out = fopen(name.c_str(), "w");
+                FILE *out = fopen(name.c_str(), "w");
                 if (out == NULL)
                     throw std::invalid_argument("Could not open privkey file for writing");
@@ -179,5 +182,5 @@
             }
             // Simplifies access from swig
-            void write_privkey(const char *name) {
+            void write_privkey_file(const char *name) {
                 write_privkey(std::string(name));
             }
@@ -225,5 +228,5 @@
             }
 
-            // returns false if there are no subjects or libstrongswan fails
+            // returns false if there are no subjects
             // throws a std::logic_error if the cert's already been baked
             bool bake() {
@@ -236,11 +239,11 @@
 
             // throws a std::logic_error if the cert isn't baked
-            void write(std::FILE *out) {
+            void write(FILE *out) {
                 int ret = abac_attribute_write(m_attr, out);
-                if (!ret) throw std::logic_error("Cert is not baked");
+                if (ret!=ABAC_SUCCESS) throw std::logic_error("Cert is not baked");
             }
 
             void write(const std::string &name) {
-                std::FILE *out = fopen(name.c_str(), "w");
+                FILE *out = fopen(name.c_str(), "w");
                 if (out == NULL)
                     throw std::invalid_argument("Could not open cert file for writing");
@@ -249,14 +252,14 @@
             }
 
-            // Simplifies access from swig
-            void write(const char *name) {
-                write(std::string(name));
+            void write_file(const char *name) {
+                int ret = abac_attribute_write_file(m_attr, name);
+                if (ret!=ABAC_SUCCESS) throw std::logic_error("Cert is not baked");
             }
 
             // throws a std::logic_error if the cert isn't baked
             abac_chunk_t cert_chunk() {
-                abac_chunk_t ret;
-                if (!baked()) throw std::logic_error("Cert is not baked");
-                abac_attribute_cert_chunk(m_attr, &ret);
+                abac_chunk_t ret=abac_attribute_cert_chunk(m_attr);
+                if(ret.len == 0)
+                    throw std::logic_error("Cert is not baked");
                 return ret;
             }
Index: libabac/abac_attribute.c
===================================================================
--- libabac/abac_attribute.c	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/abac_attribute.c	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -10,4 +10,5 @@
 
 #include "libabac_common.h"
+#include "abac_list.h"
 #include "abac_util.h"
 #include "abac_xml.h"
@@ -72,4 +73,5 @@
 
     attr->head_string = NULL;
+    asprintf(&attr->head_string,"%s.%s",abac_id_keyid(issuer_id),role);
     attr->tail_string = NULL;
 
@@ -237,16 +239,14 @@
 
 // make an explicit copy
-int abac_attribute_cert_chunk(abac_attribute_t *attr, abac_chunk_t *chunk) {
-
-    chunk->ptr=NULL;
-    chunk->len=0;
+abac_chunk_t abac_attribute_cert_chunk(abac_attribute_t *attr) {
+    abac_chunk_t chunk= {NULL,0};
 
     if (attr->cert.ptr == NULL)
-        return 0;
+        return chunk;
 
     /* return the xml chunk */
-    chunk->ptr= (unsigned char *)abac_xstrdup((char *)attr->cert.ptr);
-    chunk->len=attr->cert.len;
-    return chunk->len;
+    chunk.ptr= (unsigned char *)abac_xstrdup((char *)attr->cert.ptr);
+    chunk.len=attr->cert.len;
+    return chunk;
 }
 
@@ -295,8 +295,6 @@
 
     char **rt0s=my_read_credential(filename, &xml);
-    if(xml == NULL) return alist;
-
-    int len=strlen(xml);
-    if(len==0) return alist;
+    if(rt0s == NULL) return alist;
+    if(xml == NULL || strlen(xml)==0) return alist;
 
     abac_attribute_t *attr;
@@ -323,8 +321,9 @@
     abac_list_t *alist=abac_list_new();
     char *xml=(char *)chunk.ptr;
+    if(chunk.len==0) return alist;
+
     char **rt0s=get_rt0_from_xml(xml);
     char *rt0=NULL;
-    int len=strlen(xml);
-    if(len==0) return alist;
+    if(rt0s==NULL) return alist;
 
     abac_attribute_t *attr;
@@ -344,16 +343,32 @@
 }
 
-// returns 0 if the cert hasn't been baked
+// returns ABAC_FAILURE if the cert hasn't been baked
 int abac_attribute_write(abac_attribute_t *attr, FILE *out) {
     assert(attr != NULL);
 
     if (attr->cert.ptr == NULL)
-        return 0;
+        return ABAC_FAILURE;
 
     // write to file
     fwrite(attr->cert.ptr, attr->cert.len, 1, out);
 
-    return 1;
-}
+    return ABAC_SUCCESS;
+}
+
+// returns ABAC_FAILURE if the cert hasn't been baked
+int abac_attribute_write_file(abac_attribute_t *attr, const char *fname) {
+    if (attr->cert.ptr == NULL)
+        return ABAC_FAILURE;
+
+    FILE *fp=fopen(fname,"w+");
+    if(fp) {
+         // write to file
+         fwrite(attr->cert.ptr, attr->cert.len, 1, fp);
+    } else return ABAC_FAILURE;
+    fclose(fp);
+
+    return ABAC_SUCCESS;
+}
+
 
 void abac_attribute_free(abac_attribute_t *attr) {
Index: libabac/abac_verifier.c
===================================================================
--- libabac/abac_verifier.c	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/abac_verifier.c	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -5,5 +5,4 @@
 #include "libabac_common.h"
 #include "abac.h"
-
 #include "abac_list.h"
 #include "uthash.h"
@@ -277,5 +276,9 @@
     if (abac_list_size(attr_list) == 0)
         return ABAC_CERT_INVALID;
-    return _load_attribute_certs(attr_list,cred_list);
+
+    int ret=_load_attribute_certs(attr_list,cred_list);
+
+    if(ret) return ABAC_CERT_SUCCESS;
+        return ABAC_CERT_INVALID;
 }
 
Index: libabac/abac_verifier.h
===================================================================
--- libabac/abac_verifier.h	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/abac_verifier.h	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -3,5 +3,4 @@
 
 #include "abac.h"
-
 #include "uthash.h"
 
Index: libabac/abac_xml.c
===================================================================
--- libabac/abac_xml.c	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/abac_xml.c	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -997,5 +997,15 @@
     xmlChar **rv = NULL;                    /* return value from parse_* */
     
+    if ( !check_signature(doc) )
+        goto fail;
+    /* Parse out the type field */
     if ( !(node = xmlDocGetRootElement(doc)) )
+        goto fail;
+    if ( !(node = xmlSecFindNode(node, (xmlChar *) GENI_credential, NULL)))
+        goto fail;
+    if ( !(node = xmlSecFindNode(node, (xmlChar *) GENI_type, NULL)))
+        goto fail;
+
+    if ( !(text = get_element_content(node)) )
         goto fail;
 
Index: libabac/libabac_common.h
===================================================================
--- libabac/libabac_common.h	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/libabac_common.h	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -3,4 +3,5 @@
 
 #include "abac.h"
+#include "abac_list.h"
 
 void libabac_init();
@@ -24,4 +25,7 @@
 abac_chunk_t abac_attribute_cert(abac_attribute_t *ptr);
 
+// used by creddy
+char *abac_attribute_role_string(abac_attribute_t *attr);
+
 // called by abac_verifier 
 int init_xmlsec();
Index: libabac/prover.c
===================================================================
--- libabac/prover.c	(revision 9ac7fb4e588dd8177e62f6a2832147996b9d53ce)
+++ libabac/prover.c	(revision 472161887a4822e907c5e9d23bd1a4a0ec6f950b)
@@ -3,5 +3,5 @@
 
 #include <abac.h>
-
+#include "abac_list.h"
 #include "options.h"
 
