ASN.1 print utility: asn1#6352
Conversation
JacobBarthelmeh
left a comment
There was a problem hiding this comment.
Nice addition! Not sure how thorough the review should be here with a utility app and initial addition? If having complete review, than as it is it does not stand up to fuzz testing (it hits some crashes).
./configure --enable-all --enable-static --disable-shared CC="afl-gcc -g"
sed -i 's/-Werror//' Makefile
make
mkdir output
afl-fuzz -i ./certs -o ./output ./util/asn1 @@
That's before moving on to libfuzzer/address sanitize smoke tests.
There was a problem hiding this comment.
util/asn1.c:714:24: error: implicit conversion loses integer precision: 'size_t'
(aka 'unsigned long') to 'word32' (aka 'unsigned int')
[-Werror,-Wshorten-64-to-32]
while ((read_len = fread(data + len, 1, DATA_INC_LEN, fp)) != 0) {
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
dgarske
left a comment
There was a problem hiding this comment.
Great utility! Any reason these isn't in the wolfCLU as an asn1parse feature instead?
If it stays here please add some usage examples and README.md. Example: ./util/asn1 ./certs/server-cert.der or ./util/asn1 -p ./certs/server-cert.pem.
|
Oh man!! This is going to be a game changer!! Wish I had this about 2 weeks ago. |
There was a problem hiding this comment.
You might consider exposing this through some optional API in the library that can optionally be enabled at build-time. Then it would be easier for wolfCLU to consume. This util application can still exist. Although instead of adding another new directory consider putting in examples or scripts.
There was a problem hiding this comment.
I'll put PrintAllAsn1 and below into asn.c.
Putting into examples/asn1.
ed0dbc4 to
5459b87
Compare
dgarske
left a comment
There was a problem hiding this comment.
Very good updates! Getting close!
There was a problem hiding this comment.
examples/asn1/asn1.c: In function ‘int ReadFile(FILE*, unsigned char**, word32*)’:
examples/asn1/asn1.c:68:33: error: invalid conversion from ‘void*’ to ‘unsigned char*’ [-fpermissive]
68 | unsigned char* data = malloc(DATA_INC_LEN);
| ~~~~~~^~~~~~~~~~~~~~
| |
| void*
examples/asn1/asn1.c:84:24: error: invalid conversion from ‘void*’ to ‘unsigned char*’ [-fpermissive]
84 | p = realloc(data, len + DATA_INC_LEN);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| void*
make[2]: *** [Makefile:5884: examples/asn1/as
|
New one: |
dgarske
left a comment
There was a problem hiding this comment.
Looks like one place missed for WOLFSSL_NO_ASN_PRINT. Otherwise golden!
There was a problem hiding this comment.
Looks like there are still some WOLFSSL_NO_ASN_PRINT?
New API to parse and print DER/BER data from a buffer. Add an example to parse DER, Base64 and PEM files and print out ASN.1 items.
|
Retest this please |
1 similar comment
|
Retest this please |
|
This program does not compile on Windows. From clang-cl: examples/asn1/asn1.c(64,12): error: conflicting types for 'ReadFile'
static int ReadFile(FILE* fp, unsigned char** pdata, word32* plen)
^
f:\gv\WinKit\Include\10.0.22621.0\um\fileapi.h(979,1): note: previous declaration is here
ReadFile(
^
examples/asn1/asn1.c(125,33): error: too few arguments to function call, expected 5, have 3
if (ReadFile(fp, &data, &len) != 0) {
~~~~~~~~ ^
f:\gv\WinKit\Include\10.0.22621.0\um\fileapi.h(979,1): note: 'ReadFile' declared here
ReadFile(
^
...An easy fix for me was: --- a/examples/asn1/asn1.c 2023-08-04 09:51:41
+++ b/examples/asn1/asn1.c 2023-08-04 13:48:06
@@ -50,6 +50,9 @@
/* ASN.1 parsing state. */
static Asn1 asn1;
+#undef ReadFile
+#define ReadFile(fp, data, len) asn1_ReadFile (fp, data, len)
+
/* Read the contents of a file into a dynamically allocated buffer.
*
* Uses realloc as input may be stdin.So now a |
|
Hi @gvanem , |
Description
Add a utility to parse ASN.1 files.
Testing
How did you test?
Checklist