der.c (298192) | der.c (299736) |
---|---|
1/*- 2 * Copyright (c) 2016 Christos Zoulas 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 21 unchanged lines hidden (view full) --- 30 * https://en.wikipedia.org/wiki/X.690 31 * http://fm4dd.com/openssl/certexamples.htm 32 * http://blog.engelke.com/2014/10/17/parsing-ber-and-der-encoded-asn-1-objects/ 33 */ 34#ifndef TEST_DER 35#include "file.h" 36 37#ifndef lint | 1/*- 2 * Copyright (c) 2016 Christos Zoulas 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 21 unchanged lines hidden (view full) --- 30 * https://en.wikipedia.org/wiki/X.690 31 * http://fm4dd.com/openssl/certexamples.htm 32 * http://blog.engelke.com/2014/10/17/parsing-ber-and-der-encoded-asn-1-objects/ 33 */ 34#ifndef TEST_DER 35#include "file.h" 36 37#ifndef lint |
38FILE_RCSID("@(#)$File: der.c,v 1.4 2016/03/21 23:04:40 christos Exp $") | 38FILE_RCSID("@(#)$File: der.c,v 1.6 2016/04/21 14:26:03 christos Exp $") |
39#endif 40#endif 41 42#include <sys/types.h> 43#include <sys/stat.h> 44#include <sys/mman.h> 45 46#include <stdio.h> | 39#endif 40#endif 41 42#include <sys/types.h> 43#include <sys/stat.h> 44#include <sys/mman.h> 45 46#include <stdio.h> |
47#include <err.h> | |
48#include <fcntl.h> 49#include <stdlib.h> 50#include <string.h> 51#include <ctype.h> 52 53#ifndef TEST_DER 54#include "magic.h" 55#include "der.h" | 47#include <fcntl.h> 48#include <stdlib.h> 49#include <string.h> 50#include <ctype.h> 51 52#ifndef TEST_DER 53#include "magic.h" 54#include "der.h" |
55#else 56#include <err.h> |
|
56#endif 57 58#define DER_BAD ((uint32_t)-1) 59 60#define DER_CLASS_UNIVERSAL 0 61#define DER_CLASS_APPLICATION 1 62#define DER_CLASS_CONTEXT 2 63#define DER_CLASS_PRIVATE 3 | 57#endif 58 59#define DER_BAD ((uint32_t)-1) 60 61#define DER_CLASS_UNIVERSAL 0 62#define DER_CLASS_APPLICATION 1 63#define DER_CLASS_CONTEXT 2 64#define DER_CLASS_PRIVATE 3 |
65#ifdef DEBUG_DER |
|
64static const char der_class[] = "UACP"; | 66static const char der_class[] = "UACP"; |
67#endif |
|
65 66#define DER_TYPE_PRIMITIVE 0 67#define DER_TYPE_CONSTRUCTED 1 | 68 69#define DER_TYPE_PRIMITIVE 0 70#define DER_TYPE_CONSTRUCTED 1 |
71#ifdef DEBUG_DER |
|
68static const char der_type[] = "PC"; | 72static const char der_type[] = "PC"; |
73#endif |
|
69 70#define DER_TAG_EOC 0x00 71#define DER_TAG_BOOLEAN 0x01 72#define DER_TAG_INTEGER 0x02 73#define DER_TAG_BIT STRING 0x03 74#define DER_TAG_OCTET_STRING 0x04 75#define DER_TAG_NULL 0x05 76#define DER_TAG_OBJECT_IDENTIFIER 0x06 --- 303 unchanged lines hidden --- | 74 75#define DER_TAG_EOC 0x00 76#define DER_TAG_BOOLEAN 0x01 77#define DER_TAG_INTEGER 0x02 78#define DER_TAG_BIT STRING 0x03 79#define DER_TAG_OCTET_STRING 0x04 80#define DER_TAG_NULL 0x05 81#define DER_TAG_OBJECT_IDENTIFIER 0x06 --- 303 unchanged lines hidden --- |