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
cb90bfc2
Commit
cb90bfc2
authored
Aug 19, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new file
parent
5cbb3b0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
0 deletions
+94
-0
skeletons/tests/Makefile.am
skeletons/tests/Makefile.am
+1
-0
skeletons/tests/check-length.c
skeletons/tests/check-length.c
+93
-0
No files found.
skeletons/tests/Makefile.am
View file @
cb90bfc2
...
...
@@ -2,6 +2,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/skeletons
check_PROGRAMS
=
\
check-ber_tlv_tag
\
check-length
\
check-OIDs
\
check-GeneralizedTime
\
check-UTCTime
\
...
...
skeletons/tests/check-length.c
0 → 100644
View file @
cb90bfc2
#include <ber_decoder.c>
#include <ber_tlv_length.c>
#include <ber_tlv_tag.c>
#include <der_encoder.c>
#include <constraints.c>
#undef ADVANCE
#undef RETURN
#undef LEFT
#include <OCTET_STRING.c>
uint8_t
*
buf
;
size_t
buf_size
;
size_t
buf_off
;
static
int
write_to_buf
(
const
void
*
buffer
,
size_t
size
,
void
*
key
)
{
(
void
)
key
;
if
(
buf_off
+
size
>
buf_size
)
{
size_t
n
=
buf_size
?:
16
;
while
(
n
<
buf_off
+
size
)
n
<<=
2
;
buf
=
realloc
(
buf
,
n
);
assert
(
buf
);
buf_size
=
n
;
}
memcpy
(
buf
+
buf_off
,
buffer
,
size
);
buf_off
+=
size
;
return
0
;
}
static
void
check
(
int
size
)
{
OCTET_STRING_t
*
os
;
OCTET_STRING_t
*
nos
=
0
;
der_enc_rval_t
erval
;
ber_dec_rval_t
rval
;
int
i
;
os
=
OCTET_STRING_new_fromBuf
(
0
,
size
);
assert
(
os
);
assert
(
os
->
size
==
0
);
os
->
buf
=
malloc
(
size
);
assert
(
os
->
buf
);
os
->
size
=
size
;
for
(
i
=
0
;
i
<
size
;
i
++
)
{
os
->
buf
[
i
]
=
i
;
}
buf_off
=
0
;
erval
=
der_encode
(
&
asn1_DEF_OCTET_STRING
,
os
,
write_to_buf
,
0
);
assert
(
erval
.
encoded
==
buf_off
);
assert
(
buf_off
>
size
);
rval
=
ber_decode
(
&
asn1_DEF_OCTET_STRING
,
&
nos
,
buf
,
buf_off
);
assert
(
rval
.
code
==
RC_OK
);
assert
(
rval
.
consumed
==
buf_off
);
assert
(
os
->
size
==
nos
->
size
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
assert
(
os
->
buf
[
i
]
==
nos
->
buf
[
i
]);
}
if
(
0
)
{
printf
(
"new(%d):"
,
size
);
for
(
i
=
0
;
i
<
(
buf_off
<
10
?
buf_off
:
10
);
i
++
)
printf
(
" %02x"
,
buf
[
i
]);
printf
(
"
\n
"
);
}
asn1_DEF_OCTET_STRING
.
free_struct
(
&
asn1_DEF_OCTET_STRING
,
os
,
0
);
asn1_DEF_OCTET_STRING
.
free_struct
(
&
asn1_DEF_OCTET_STRING
,
nos
,
0
);
}
int
main
()
{
int
i
;
for
(
i
=
0
;
i
<
66000
;
i
++
)
{
if
(
i
==
4500
)
i
=
64000
;
check
(
i
);
}
return
0
;
}
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