[BACK]Return to crypto_openssl.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / crypto / dist / ipsec-tools / src / racoon

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/crypto/dist/ipsec-tools/src/racoon/crypto_openssl.c between version 1.16 and 1.17

version 1.16, 2009/01/10 19:08:40 version 1.17, 2009/03/12 10:57:26
Line 107  typedef STACK_OF(GENERAL_NAME) GENERAL_N
Line 107  typedef STACK_OF(GENERAL_NAME) GENERAL_N
 #include "crypto_openssl.h"  #include "crypto_openssl.h"
 #include "debug.h"  #include "debug.h"
 #include "gcmalloc.h"  #include "gcmalloc.h"
   #include "isakmp.h"
   
 /*  /*
  * I hate to cast every parameter to des_xx into void *, but it is   * I hate to cast every parameter to des_xx into void *, but it is
Line 613  cb_check_cert_remote(ok, ctx)
Line 614  cb_check_cert_remote(ok, ctx)
 }  }
   
 /*  /*
  * get a subjectAltName from X509 certificate.   * get a subjectName from X509 certificate.
  */   */
 vchar_t *  vchar_t *
 eay_get_x509asn1subjectname(cert)  eay_get_x509asn1subjectname(cert)
Line 624  eay_get_x509asn1subjectname(cert)
Line 625  eay_get_x509asn1subjectname(cert)
         vchar_t *name = NULL;          vchar_t *name = NULL;
         int len;          int len;
   
         bp = (unsigned char *) cert->v;  
   
         x509 = mem2x509(cert);          x509 = mem2x509(cert);
         if (x509 == NULL)          if (x509 == NULL)
                 goto error;                  goto error;
Line 759  end:
Line 758  end:
         return error;          return error;
 }  }
   
   /*
    * get a issuerName from X509 certificate.
    */
   vchar_t *
   eay_get_x509asn1issuername(cert)
           vchar_t *cert;
   {
           X509 *x509 = NULL;
           u_char *bp;
           vchar_t *name = NULL;
           int len;
   
           x509 = mem2x509(cert);
           if (x509 == NULL)
                   goto error;
   
           /* get the length of the name */
           len = i2d_X509_NAME(x509->cert_info->issuer, NULL);
           name = vmalloc(len);
           if (name == NULL)
                   goto error;
   
           /* get the name */
           bp = (unsigned char *) name->v;
           len = i2d_X509_NAME(x509->cert_info->issuer, &bp);
   
           X509_free(x509);
   
           return name;
   
   error:
           plog(LLV_ERROR, LOCATION, NULL, "%s\n", eay_strerror());
   
           if (name != NULL)
                   vfree(name);
           if (x509 != NULL)
                   X509_free(x509);
   
           return NULL;
   }
   
 /*  /*
  * decode a X509 certificate and make a readable text terminated '\n'.   * decode a X509 certificate and make a readable text terminated '\n'.
Line 825  mem2x509(cert)
Line 864  mem2x509(cert)
     {      {
         u_char *bp;          u_char *bp;
   
         bp = (unsigned char *) cert->v;          bp = (unsigned char *) cert->v + 1;
   
         x509 = d2i_X509(NULL, (void *)&bp, cert->l);          x509 = d2i_X509(NULL, (void *)&bp, cert->l - 1);
     }      }
 #else  #else
     {      {
Line 837  mem2x509(cert)
Line 876  mem2x509(cert)
         bio = BIO_new(BIO_s_mem());          bio = BIO_new(BIO_s_mem());
         if (bio == NULL)          if (bio == NULL)
                 return NULL;                  return NULL;
         len = BIO_write(bio, cert->v, cert->l);          len = BIO_write(bio, cert->v + 1, cert->l - 1);
         if (len == -1)          if (len == -1)
                 return NULL;                  return NULL;
         x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);          x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
Line 878  eay_get_x509cert(path)
Line 917  eay_get_x509cert(path)
                 return NULL;                  return NULL;
   
         len = i2d_X509(x509, NULL);          len = i2d_X509(x509, NULL);
         cert = vmalloc(len);          cert = vmalloc(len + 1);
         if (cert == NULL) {          if (cert == NULL) {
                 X509_free(x509);                  X509_free(x509);
                 return NULL;                  return NULL;
         }          }
         bp = (unsigned char *) cert->v;          cert->v[0] = ISAKMP_CERT_X509SIGN;
           bp = (unsigned char *) &cert->v[1];
         error = i2d_X509(x509, &bp);          error = i2d_X509(x509, &bp);
         X509_free(x509);          X509_free(x509);
   
Line 909  eay_check_x509sign(source, sig, cert)
Line 949  eay_check_x509sign(source, sig, cert)
         vchar_t *cert;          vchar_t *cert;
 {  {
         X509 *x509;          X509 *x509;
         u_char *bp;  
         EVP_PKEY *evp;          EVP_PKEY *evp;
         int res;          int res;
   
         bp = (unsigned char *) cert->v;          x509 = mem2x509(cert);
           if (x509 == NULL)
         x509 = d2i_X509(NULL, (void *)&bp, cert->l);  
         if (x509 == NULL) {  
                 plog(LLV_ERROR, LOCATION, NULL, "d2i_X509(): %s\n", eay_strerror());  
                 return -1;                  return -1;
         }  
   
         evp = X509_get_pubkey(x509);          evp = X509_get_pubkey(x509);
         if (! evp) {          if (! evp) {

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

CVSweb <webmaster@jp.NetBSD.org>