Blame asn1.h

Packit Service 09cdfc
/* 
Packit Service 09cdfc
   Unix SMB/CIFS implementation.   
Packit Service 09cdfc
   simple ASN1 code
Packit Service 09cdfc
   Copyright (C) Andrew Tridgell 2001
Packit Service 09cdfc
   
Packit Service 09cdfc
   This program is free software; you can redistribute it and/or modify
Packit Service 09cdfc
   it under the terms of the GNU General Public License as published by
Packit Service 09cdfc
   the Free Software Foundation; either version 3 of the License, or
Packit Service 09cdfc
   (at your option) any later version.
Packit Service 09cdfc
   
Packit Service 09cdfc
   This program is distributed in the hope that it will be useful,
Packit Service 09cdfc
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 09cdfc
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 09cdfc
   GNU General Public License for more details.
Packit Service 09cdfc
   
Packit Service 09cdfc
   You should have received a copy of the GNU General Public License
Packit Service 09cdfc
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 09cdfc
*/
Packit Service 09cdfc
Packit Service 09cdfc
#ifndef _ASN_1_H
Packit Service 09cdfc
#define _ASN_1_H
Packit Service 09cdfc
Packit Service 09cdfc
struct nesting {
Packit Service 09cdfc
	off_t start;
Packit Service 09cdfc
	size_t taglen; /* for parsing */
Packit Service 09cdfc
	struct nesting *next;
Packit Service 09cdfc
};
Packit Service 09cdfc
Packit Service 09cdfc
struct asn1_data {
Packit Service 09cdfc
	uint8_t *data;
Packit Service 09cdfc
	size_t length;
Packit Service 09cdfc
	off_t ofs;
Packit Service 09cdfc
	struct nesting *nesting;
Packit Service 09cdfc
	bool has_error;
Packit Service 09cdfc
};
Packit Service 09cdfc
Packit Service 09cdfc
typedef struct asn1_data ASN1_DATA;
Packit Service 09cdfc
Packit Service 09cdfc
#define ASN1_APPLICATION(x) ((x)+0x60)
Packit Service 09cdfc
#define ASN1_APPLICATION_SIMPLE(x) ((x)+0x40)
Packit Service 09cdfc
#define ASN1_SEQUENCE(x) ((x)+0x30)
Packit Service 09cdfc
#define ASN1_CONTEXT(x) ((x)+0xa0)
Packit Service 09cdfc
#define ASN1_CONTEXT_SIMPLE(x) ((x)+0x80)
Packit Service 09cdfc
#define ASN1_GENERAL_STRING 0x1b
Packit Service 09cdfc
#define ASN1_OCTET_STRING 0x4
Packit Service 09cdfc
#define ASN1_OID 0x6
Packit Service 09cdfc
#define ASN1_BOOLEAN 0x1
Packit Service 09cdfc
#define ASN1_INTEGER 0x2
Packit Service 09cdfc
#define ASN1_BIT_STRING 0x3
Packit Service 09cdfc
#define ASN1_ENUMERATED 0xa
Packit Service 09cdfc
#define ASN1_SET 0x31
Packit Service 09cdfc
Packit Service 09cdfc
#define ASN1_MAX_OIDS 20
Packit Service 09cdfc
Packit Service 09cdfc
struct asn1_data *asn1_init(TALLOC_CTX *mem_ctx);
Packit Service 09cdfc
void asn1_free(struct asn1_data *data);
Packit Service 09cdfc
bool asn1_write(struct asn1_data *data, const void *p, int len);
Packit Service 09cdfc
bool asn1_write_uint8(struct asn1_data *data, uint8_t v);
Packit Service 09cdfc
bool asn1_push_tag(struct asn1_data *data, uint8_t tag);
Packit Service 09cdfc
bool asn1_pop_tag(struct asn1_data *data);
Packit Service 09cdfc
bool ber_write_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *OID);
Packit Service 09cdfc
bool asn1_write_OID(struct asn1_data *data, const char *OID);
Packit Service 09cdfc
bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length);
Packit Service 09cdfc
#endif /* _ASN_1_H */