summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFabio Fiorina <fiorinaf@gnutls.org>2003-07-30 19:50:34 +0000
committerFabio Fiorina <fiorinaf@gnutls.org>2003-07-30 19:50:34 +0000
commitf75e8e5f5e3f77b6b19bdfe625abb94ae3664088 (patch)
tree647f366e88b27253e7037f007ca4f4fb0e997d74 /src
parent84f25fcf992e5d7285c6d5d9734c1f88539dc50e (diff)
downloadlibtasn1-f75e8e5f5e3f77b6b19bdfe625abb94ae3664088.tar.gz
libtasn1-f75e8e5f5e3f77b6b19bdfe625abb94ae3664088.tar.bz2
libtasn1-f75e8e5f5e3f77b6b19bdfe625abb94ae3664088.zip
Add BER decoding
Diffstat (limited to 'src')
-rw-r--r--src/CertificateExample.c1
-rw-r--r--src/CrlExample.c1
-rw-r--r--src/asn1Coding.c2
-rw-r--r--src/asn1Decoding.c48
-rw-r--r--src/asn1Parser.c2
-rw-r--r--src/asn1c.c1
6 files changed, 48 insertions, 7 deletions
diff --git a/src/CertificateExample.c b/src/CertificateExample.c
index fc60cf9..1c1c868 100644
--- a/src/CertificateExample.c
+++ b/src/CertificateExample.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "libtasn1.h"
diff --git a/src/CrlExample.c b/src/CrlExample.c
index 2eba8c9..8c5d400 100644
--- a/src/CrlExample.c
+++ b/src/CrlExample.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "libtasn1.h"
diff --git a/src/asn1Coding.c b/src/asn1Coding.c
index 0480c77..aaefe07 100644
--- a/src/asn1Coding.c
+++ b/src/asn1Coding.c
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <libtasn1.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <config.h>
#ifdef HAVE_UNISTD_H
diff --git a/src/asn1Decoding.c b/src/asn1Decoding.c
index 780ab9c..903e145 100644
--- a/src/asn1Decoding.c
+++ b/src/asn1Decoding.c
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <libtasn1.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <config.h>
#ifdef HAVE_UNISTD_H
@@ -92,8 +92,9 @@ main(int argc,char *argv[])
char errorDescription[MAX_ERROR_DESCRIPTION_SIZE];
int asn1_result=ASN1_SUCCESS;
FILE *inputFile;
- unsigned char der[1024];
+ unsigned char der[100*1024];
int der_len=0;
+ /* FILE *outputFile; */
opterr=0; /* disable error messages from getopt */
@@ -192,7 +193,7 @@ main(int argc,char *argv[])
inputFile=fopen(inputFileDerName,"r");
-
+
if(inputFile==NULL){
printf("asn1Decoding: file '%s' not found\n",inputFileDerName);
asn1_delete_structure(&definitions);
@@ -203,13 +204,33 @@ main(int argc,char *argv[])
exit(1);
}
- while(fscanf(inputFile,"%c",der+der_len) != EOF)
- der_len++;
+ /*****************************************/
+ /* ONLY FOR TEST */
+ /*****************************************/
+ /*
+ der_len=0;
+ outputFile=fopen("data.p12","w");
+ while(fscanf(inputFile,"%c",der+der_len) != EOF){
+ if((der_len>=0x11) && (der_len<=(0xe70)))
+ fprintf(outputFile,"%c",der[der_len]);
+ der_len++;
+ }
+ fclose(outputFile);
fclose(inputFile);
+ */
+
+ while(fscanf(inputFile,"%c",der+der_len) != EOF){
+ der_len++;
+ }
+ fclose(inputFile);
+
asn1_result=asn1_create_element(definitions,typeName,&structure);
+ /* asn1_print_structure(stdout,structure,"",ASN1_PRINT_ALL); */
+
+
if(asn1_result != ASN1_SUCCESS){
printf("Structure creation: %s\n",libtasn1_strerror(asn1_result));
asn1_delete_structure(&definitions);
@@ -228,6 +249,21 @@ main(int argc,char *argv[])
printf("\nDECODING RESULT:\n");
asn1_print_structure(stdout,structure,"",ASN1_PRINT_NAME_TYPE_VALUE);
+ /*****************************************/
+ /* ONLY FOR TEST */
+ /*****************************************/
+ /*
+ der_len=10000;
+ option_index=0;
+ asn1_result=asn1_read_value(structure,"?2.content",der,&der_len);
+ outputFile=fopen("encryptedData.p12","w");
+ while(der_len>0){
+ fprintf(outputFile,"%c",der[option_index]);
+ der_len--;
+ option_index++;
+ }
+ fclose(outputFile);
+ */
asn1_delete_structure(&definitions);
asn1_delete_structure(&structure);
@@ -246,3 +282,5 @@ main(int argc,char *argv[])
+
+
diff --git a/src/asn1Parser.c b/src/asn1Parser.c
index e071ad9..009ccff 100644
--- a/src/asn1Parser.c
+++ b/src/asn1Parser.c
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <libtasn1.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <config.h>
#ifdef HAVE_UNISTD_H
diff --git a/src/asn1c.c b/src/asn1c.c
index 8c9b43f..dc75dd9 100644
--- a/src/asn1c.c
+++ b/src/asn1c.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "libtasn1.h"
int