Blame asn1.h

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