2004-06-03 03:38:44 +00:00
|
|
|
/*-
|
2017-10-18 04:27:33 +00:00
|
|
|
* Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
2004-06-03 03:38:44 +00:00
|
|
|
* Redistribution and modifications are permitted subject to BSD license.
|
|
|
|
*/
|
|
|
|
#ifndef _OCTET_STRING_H_
|
|
|
|
#define _OCTET_STRING_H_
|
|
|
|
|
2004-09-24 21:00:50 +00:00
|
|
|
#include <asn_application.h>
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2005-07-24 09:03:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-06-03 03:38:44 +00:00
|
|
|
typedef struct OCTET_STRING {
|
|
|
|
uint8_t *buf; /* Buffer with consecutive OCTET_STRING bits */
|
2017-08-08 03:07:00 +00:00
|
|
|
size_t size; /* Size of the buffer */
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2004-09-29 13:26:15 +00:00
|
|
|
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
|
2004-06-03 03:38:44 +00:00
|
|
|
} OCTET_STRING_t;
|
|
|
|
|
2004-09-29 13:26:15 +00:00
|
|
|
extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING;
|
Move type operations to another structure
Every type has free, print, check_constraints, ber_decoder, der_encoder,
xer_decoder, xer_encoder, uper_decoder, uper_encoder and outmost_tag
operations. We move them out to a separate structure asn_TYPE_operation_t.
Combined with previous logic simplification, these operations are based
on ASN.1 basic types, constructed types and string types. So we can
reduce the space occupied by asn_TYPE_descriptor_t variables.
2017-08-19 17:25:45 +00:00
|
|
|
extern asn_TYPE_operation_t asn_OP_OCTET_STRING;
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2004-09-22 16:06:28 +00:00
|
|
|
asn_struct_free_f OCTET_STRING_free;
|
2004-06-03 03:38:44 +00:00
|
|
|
asn_struct_print_f OCTET_STRING_print;
|
2004-10-20 15:50:55 +00:00
|
|
|
asn_struct_print_f OCTET_STRING_print_utf8;
|
2017-08-10 09:14:59 +00:00
|
|
|
asn_struct_compare_f OCTET_STRING_compare;
|
2004-09-22 16:06:28 +00:00
|
|
|
ber_type_decoder_f OCTET_STRING_decode_ber;
|
|
|
|
der_type_encoder_f OCTET_STRING_encode_der;
|
2004-10-20 15:50:55 +00:00
|
|
|
xer_type_decoder_f OCTET_STRING_decode_xer_hex; /* Hexadecimal */
|
|
|
|
xer_type_decoder_f OCTET_STRING_decode_xer_binary; /* 01010111010 */
|
|
|
|
xer_type_decoder_f OCTET_STRING_decode_xer_utf8; /* ASCII/UTF-8 */
|
2004-09-22 16:06:28 +00:00
|
|
|
xer_type_encoder_f OCTET_STRING_encode_xer;
|
2004-10-20 15:50:55 +00:00
|
|
|
xer_type_encoder_f OCTET_STRING_encode_xer_utf8;
|
2017-07-25 14:58:05 +00:00
|
|
|
oer_type_decoder_f OCTET_STRING_decode_oer;
|
|
|
|
oer_type_encoder_f OCTET_STRING_encode_oer;
|
2005-11-26 11:25:14 +00:00
|
|
|
per_type_decoder_f OCTET_STRING_decode_uper;
|
2006-08-18 01:34:18 +00:00
|
|
|
per_type_encoder_f OCTET_STRING_encode_uper;
|
2017-09-30 06:15:58 +00:00
|
|
|
asn_random_fill_f OCTET_STRING_random_fill;
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2016-05-16 05:50:09 +00:00
|
|
|
#define OCTET_STRING_constraint asn_generic_no_constraint
|
|
|
|
#define OCTET_STRING_decode_xer OCTET_STRING_decode_xer_hex
|
|
|
|
|
2004-10-12 05:57:23 +00:00
|
|
|
/******************************
|
|
|
|
* Handy conversion routines. *
|
|
|
|
******************************/
|
2004-06-03 03:38:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This function clears the previous value of the OCTET STRING (if any)
|
2006-03-17 18:34:10 +00:00
|
|
|
* and then allocates a new memory with the specified content (str/size).
|
2004-09-02 12:11:47 +00:00
|
|
|
* If size = -1, the size of the original string will be determined
|
2004-06-03 03:38:44 +00:00
|
|
|
* using strlen(str).
|
|
|
|
* If str equals to NULL, the function will silently clear the
|
|
|
|
* current contents of the OCTET STRING.
|
|
|
|
* Returns 0 if it was possible to perform operation, -1 otherwise.
|
|
|
|
*/
|
|
|
|
int OCTET_STRING_fromBuf(OCTET_STRING_t *s, const char *str, int size);
|
|
|
|
|
2004-10-12 05:57:23 +00:00
|
|
|
/* Handy conversion from the C string into the OCTET STRING. */
|
2005-04-18 05:41:08 +00:00
|
|
|
#define OCTET_STRING_fromString(s, str) OCTET_STRING_fromBuf(s, str, -1)
|
2004-10-12 05:57:23 +00:00
|
|
|
|
2004-06-03 03:38:44 +00:00
|
|
|
/*
|
|
|
|
* Allocate and fill the new OCTET STRING and return a pointer to the newly
|
|
|
|
* allocated object. NULL is permitted in str: the function will just allocate
|
|
|
|
* empty OCTET STRING.
|
|
|
|
*/
|
2017-09-30 06:15:58 +00:00
|
|
|
OCTET_STRING_t *OCTET_STRING_new_fromBuf(const asn_TYPE_descriptor_t *td,
|
|
|
|
const char *str, int size);
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2004-10-12 05:57:23 +00:00
|
|
|
/****************************
|
|
|
|
* Internally useful stuff. *
|
|
|
|
****************************/
|
|
|
|
|
2017-10-03 23:33:59 +00:00
|
|
|
typedef struct asn_OCTET_STRING_specifics_s {
|
2017-10-18 23:30:05 +00:00
|
|
|
/*
|
|
|
|
* Target structure description.
|
|
|
|
*/
|
|
|
|
unsigned struct_size; /* Size of the structure */
|
|
|
|
unsigned ctx_offset; /* Offset of the asn_struct_ctx_t member */
|
|
|
|
|
|
|
|
enum asn_OS_Subvariant {
|
|
|
|
ASN_OSUBV_ANY, /* The open type (ANY) */
|
|
|
|
ASN_OSUBV_BIT, /* BIT STRING */
|
|
|
|
ASN_OSUBV_STR, /* String types, not {BMP,Universal}String */
|
|
|
|
ASN_OSUBV_U16, /* 16-bit character (BMPString) */
|
|
|
|
ASN_OSUBV_U32 /* 32-bit character (UniversalString) */
|
|
|
|
} subvariant;
|
2004-10-12 05:57:23 +00:00
|
|
|
} asn_OCTET_STRING_specifics_t;
|
2004-06-03 03:38:44 +00:00
|
|
|
|
2016-05-16 05:50:09 +00:00
|
|
|
extern asn_OCTET_STRING_specifics_t asn_SPC_OCTET_STRING_specs;
|
|
|
|
|
2017-10-14 07:23:09 +00:00
|
|
|
size_t OCTET_STRING_random_length_constrained(
|
|
|
|
const asn_TYPE_descriptor_t *, const asn_encoding_constraints_t *,
|
|
|
|
size_t max_length);
|
|
|
|
|
2005-07-24 09:03:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-03 03:38:44 +00:00
|
|
|
#endif /* _OCTET_STRING_H_ */
|