ReactOS  0.4.12-dev-75-g00dd17e
asn.c File Reference
#include "precomp.h"
Include dependency graph for asn.c:

Go to the source code of this file.

Functions

RD_BOOL ber_parse_header (STREAM s, int tagval, int *length)
 
void ber_out_header (STREAM s, int tagval, int length)
 
void ber_out_integer (STREAM s, int value)
 
RD_BOOL ber_in_header (STREAM s, int *tagval, int *decoded_len)
 

Function Documentation

◆ ber_in_header()

RD_BOOL ber_in_header ( STREAM  s,
int tagval,
int decoded_len 
)

Definition at line 90 of file asn.c.

91 {
92  in_uint8(s, *tagval);
93  in_uint8(s, *decoded_len);
94 
95  if (*decoded_len < 0x80)
96  return True;
97  else if (*decoded_len == 0x81)
98  {
99  in_uint8(s, *decoded_len);
100  return True;
101  }
102  else if (*decoded_len == 0x82)
103  {
104  in_uint16_be(s, *decoded_len);
105  return True;
106  }
107 
108  return False;
109 }
#define True
Definition: types.h:24
#define False
Definition: types.h:25
#define in_uint8(s, v)
Definition: parse.h:88
#define in_uint16_be(s, v)
Definition: parse.h:75

◆ ber_out_header()

void ber_out_header ( STREAM  s,
int  tagval,
int  length 
)

Definition at line 61 of file asn.c.

Referenced by ber_out_integer().

62 {
63  if (tagval > 0xff)
64  {
65  out_uint16_be(s, tagval);
66  }
67  else
68  {
69  out_uint8(s, tagval);
70  }
71 
72  if (length >= 0x80)
73  {
74  out_uint8(s, 0x82);
76  }
77  else
78  out_uint8(s, length);
79 }
#define out_uint8(s, v)
Definition: parse.h:92
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define out_uint16_be(s, v)
Definition: parse.h:77

◆ ber_out_integer()

void ber_out_integer ( STREAM  s,
int  value 
)

Definition at line 83 of file asn.c.

84 {
86  out_uint16_be(s, value);
87 }
Definition: get.c:139
void ber_out_header(STREAM s, int tagval, int length)
Definition: asn.c:61
#define BER_TAG_INTEGER
Definition: constants.h:78
#define out_uint16_be(s, v)
Definition: parse.h:77

◆ ber_parse_header()

RD_BOOL ber_parse_header ( STREAM  s,
int  tagval,
int length 
)

Definition at line 25 of file asn.c.

26 {
27  int tag, len;
28 
29  if (tagval > 0xff)
30  {
31  in_uint16_be(s, tag);
32  }
33  else
34  {
35  in_uint8(s, tag);
36  }
37 
38  if (tag != tagval)
39  {
40  error("expected tag %d, got %d\n", tagval, tag);
41  return False;
42  }
43 
44  in_uint8(s, len);
45 
46  if (len & 0x80)
47  {
48  len &= ~0x80;
49  *length = 0;
50  while (len--)
51  next_be(s, *length);
52  }
53  else
54  *length = len;
55 
56  return s_check(s);
57 }
#define error(str)
Definition: mkdosfs.c:1605
#define s_check(s)
Definition: parse.h:42
#define False
Definition: types.h:25
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLenum GLsizei len
Definition: glext.h:6722
#define in_uint8(s, v)
Definition: parse.h:88
#define next_be(s, v)
Definition: parse.h:97
#define in_uint16_be(s, v)
Definition: parse.h:75
char * tag
Definition: main.c:59