Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
a737f3b4
Commit
a737f3b4
authored
Sep 02, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preliminary ANY support
parent
cec43b58
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
11 deletions
+73
-11
skeletons/ANY.c
skeletons/ANY.c
+23
-0
skeletons/ANY.h
skeletons/ANY.h
+32
-0
skeletons/OCTET_STRING.c
skeletons/OCTET_STRING.c
+14
-8
skeletons/OCTET_STRING.h
skeletons/OCTET_STRING.h
+2
-2
skeletons/file-dependencies
skeletons/file-dependencies
+2
-1
No files found.
skeletons/ANY.c
0 → 100644
View file @
a737f3b4
/*-
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <ANY.h>
#include <assert.h>
#include <errno.h>
asn1_TYPE_descriptor_t
asn1_DEF_ANY
=
{
"ANY"
,
asn_generic_no_constraint
,
OCTET_STRING_decode_ber
,
OCTET_STRING_encode_der
,
OCTET_STRING_print
,
OCTET_STRING_free
,
0
,
/* Use generic outmost tag fetcher */
0
,
0
,
0
,
/* No tags may be overridden */
-
1
,
/* Both ways are fine (primitive and constructed) */
0
,
0
,
/* No members */
(
void
*
)
1
/* Special indicator that this is an ANY type */
};
skeletons/ANY.h
0 → 100644
View file @
a737f3b4
/*-
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef ASN_TYPE_ANY_H
#define ASN_TYPE_ANY_H
#include <constr_TYPE.h>
#include <OCTET_STRING.h>
/* Implemented via OCTET SRING type */
typedef
struct
ANY
{
uint8_t
*
buf
;
/* BER-encoded ANY contents */
int
size
;
/* Size of the above buffer */
ber_dec_ctx_t
_ber_dec_ctx
;
/* Parsing across buffer boundaries */
}
ANY_t
;
extern
asn1_TYPE_descriptor_t
asn1_DEF_ANY
;
ber_type_decoder_f
ANY_decode_ber
;
der_type_encoder_f
ANY_encode_der
;
asn_struct_print_f
ANY_print
;
asn_struct_free_f
ANY_free
;
/******************************
* Handy conversion routines. *
******************************/
#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf((buf), (size))
#endif
/* ASN_TYPE_ANY_H */
skeletons/OCTET_STRING.c
View file @
a737f3b4
...
...
@@ -150,7 +150,7 @@ OCTET_STRING_decode_ber(asn1_TYPE_descriptor_t *td,
* This is a some sort of a hack.
* The OCTET STRING decoder is being used in BIT STRING mode.
*/
int
is_bit_str
=
td
->
specifics
?
1
:
0
;
int
is_bit_str
=
(
td
->
specifics
==
(
void
*
)
-
1
)
?
1
:
0
;
ASN_DEBUG
(
"Decoding %s as %s (%ld)"
,
td
->
name
,
...
...
@@ -395,6 +395,8 @@ OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
der_enc_rval_t
erval
;
OCTET_STRING_t
*
st
=
(
OCTET_STRING_t
*
)
ptr
;
int
add_byte
=
0
;
int
is_bit_str
=
(
td
->
specifics
==
(
void
*
)
-
1
);
int
is_ANY_type
=
(
td
->
specifics
==
(
void
*
)
1
;
ASN_DEBUG
(
"%s %s as OCTET STRING"
,
cb
?
"Estimating"
:
"Encoding"
,
sd
->
name
);
...
...
@@ -402,7 +404,7 @@ OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
/*
* Canonicalize BIT STRING.
*/
if
(
sd
->
specifics
&&
st
->
buf
)
{
if
(
is_bit_str
&&
st
->
buf
)
{
switch
(
st
->
size
)
{
case
0
:
add_byte
=
1
;
break
;
case
1
:
st
->
buf
[
0
]
=
0
;
break
;
...
...
@@ -412,12 +414,16 @@ OCTET_STRING_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
}
}
erval
.
encoded
=
der_write_tags
(
sd
,
st
->
size
+
add_byte
,
tag_mode
,
tag
,
cb
,
app_key
);
if
(
erval
.
encoded
==
-
1
)
{
erval
.
failed_type
=
sd
;
erval
.
structure_ptr
=
ptr
;
return
erval
;
if
(
is_ANY_type
)
{
erval
.
encoded
=
0
;
}
else
{
erval
.
encoded
=
der_write_tags
(
sd
,
st
->
size
+
add_byte
,
tag_mode
,
tag
,
cb
,
app_key
);
if
(
erval
.
encoded
==
-
1
)
{
erval
.
failed_type
=
sd
;
erval
.
structure_ptr
=
ptr
;
return
erval
;
}
}
if
(
cb
)
{
...
...
skeletons/OCTET_STRING.h
View file @
a737f3b4
...
...
@@ -28,8 +28,8 @@ asn_struct_free_f OCTET_STRING_free;
/*
* This function clears the previous value of the OCTET STRING (if any)
* and then allocates a new memory and
makes s point to the newly allocated
*
memory.
If size = -1, the size of the original string will be determined
* and then allocates a new memory and
returns a pointer to it.
* If size = -1, the size of the original string will be determined
* using strlen(str).
* If str equals to NULL, the function will silently clear the
* current contents of the OCTET STRING.
...
...
skeletons/file-dependencies
View file @
a737f3b4
...
...
@@ -6,6 +6,7 @@
# $Id$
#
ANY.h ANY.h
BIT_STRING.h BIT_STRING.c
BMPString.h BMPString.c
BOOLEAN.h BOOLEAN.c
...
...
@@ -25,7 +26,7 @@ ObjectDescriptor.h ObjectDescriptor.c GraphicString.h
PrintableString.h PrintableString.c
RELATIVE-OID.h RELATIVE-OID.c OBJECT-IDENTIFIER.h
T61String.h T61String.c
TeletexString.h TeletexString.c
TeletexString.h TeletexString.c
UTCTime.h UTCTime.c GeneralizedTime.h
UTF8String.h UTF8String.c
UniversalString.h UniversalString.c
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment