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
c4676a80
Commit
c4676a80
authored
Nov 16, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
der_encode_to_buffer()
parent
b54577ae
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
0 deletions
+53
-0
ChangeLog
ChangeLog
+1
-0
skeletons/der_encoder.c
skeletons/der_encoder.c
+44
-0
skeletons/der_encoder.h
skeletons/der_encoder.h
+8
-0
No files found.
ChangeLog
View file @
c4676a80
...
...
@@ -15,6 +15,7 @@
* ber_dec_rval_t renamed into asn_dec_rval_t: more generality.
* Removed order dependency in DEFAULT references to ENUMERATED
identifiers (./tests/68-*-OK.asn1).
* Implemented der_encode_to_buffer() procedure.
0.9.7.1: 2004-Oct-12
...
...
skeletons/der_encoder.c
View file @
c4676a80
...
...
@@ -28,6 +28,50 @@ der_encode(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr,
consume_bytes
,
app_key
);
}
/*
* Argument type and callback necessary for der_encode_to_buffer().
*/
typedef
struct
enc_to_buf_arg
{
void
*
buffer
;
size_t
left
;
}
enc_to_buf_arg
;
static
int
encode_to_buffer_cb
(
const
void
*
buffer
,
size_t
size
,
void
*
key
)
{
enc_to_buf_arg
*
arg
=
key
;
if
(
arg
->
left
<
size
)
return
-
1
;
/* Data exceeds the available buffer size */
memcpy
(
arg
->
buffer
,
buffer
,
size
);
arg
->
buffer
=
((
char
*
)
arg
->
buffer
)
+
size
;
arg
->
left
-=
size
;
return
0
;
}
/*
* A variant of the der_encode() which encodes the data into the provided buffer
*/
asn_enc_rval_t
der_encode_to_buffer
(
asn_TYPE_descriptor_t
*
type_descriptor
,
void
*
struct_ptr
,
void
*
buffer
,
size_t
*
buffer_size
)
{
enc_to_buf_arg
arg
;
asn_enc_rval_t
ec
;
arg
.
buffer
=
buffer
;
arg
.
left
=
*
buffer_size
;
ec
=
type_descriptor
->
der_encoder
(
type_descriptor
,
struct_ptr
,
/* Pointer to the destination structure */
0
,
0
,
encode_to_buffer_cb
,
&
arg
);
if
(
ec
.
encoded
!=
-
1
)
{
assert
(
ec
.
encoded
==
(
*
buffer_size
-
arg
.
left
));
/* Return the encoded contents size */
*
buffer_size
=
ec
.
encoded
;
}
return
ec
;
}
/*
* Write out leading TL[v] sequence according to the type definition.
*/
...
...
skeletons/der_encoder.h
View file @
c4676a80
...
...
@@ -18,6 +18,14 @@ asn_enc_rval_t der_encode(struct asn_TYPE_descriptor_s *type_descriptor,
void
*
app_key
/* Arbitrary callback argument */
);
/* A variant of der_encode() which encodes data into the pre-allocated buffer */
asn_enc_rval_t
der_encode_to_buffer
(
struct
asn_TYPE_descriptor_s
*
type_descriptor
,
void
*
struct_ptr
,
/* Structure to be encoded */
void
*
buffer
,
/* Pre-allocated buffer */
size_t
*
buffer_size
/* Initial buffer size (max) */
);
/*
* Type of the generic DER encoder.
*/
...
...
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