Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asn1c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
qwebaby3
asn1c
Commits
8f3b506a
Commit
8f3b506a
authored
20 years ago
by
Lev Walkin
Browse files
Options
Downloads
Patches
Plain Diff
even better
parent
b2ce577f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
skeletons/ber_tlv_tag.c
+10
-10
10 additions, 10 deletions
skeletons/ber_tlv_tag.c
with
10 additions
and
10 deletions
skeletons/ber_tlv_tag.c
+
10
−
10
View file @
8f3b506a
...
...
@@ -17,7 +17,7 @@ ber_fetch_tag(void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
val
=
*
(
uint8_t
*
)
ptr
;
tclass
=
(
val
>>
6
);
if
((
val
&=
31
)
!=
31
)
{
if
((
val
&=
0x1F
)
!=
0x1F
)
{
/*
* Simple form: everything encoded in a single octet.
* Tag Class is encoded using two least significant bits.
...
...
@@ -31,8 +31,8 @@ ber_fetch_tag(void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
* The MSB is 0 if it is the last octet of the tag.
*/
for
(
val
=
0
,
((
char
*
)
ptr
)
++
,
skipped
=
2
;
skipped
<
size
;
((
char
*
)
ptr
)
++
,
skipped
++
)
{
unsigned
oct
=
*
(
uint8_t
*
)
ptr
;
skipped
<
=
size
;
((
char
*
)
ptr
)
++
,
skipped
++
)
{
unsigned
int
oct
=
*
(
uint8_t
*
)
ptr
;
if
(
oct
&
0x80
)
{
val
=
(
val
<<
7
)
|
(
oct
&
0x7F
);
/*
...
...
@@ -47,7 +47,8 @@ ber_fetch_tag(void *ptr, size_t size, ber_tlv_tag_t *tag_r) {
return
-
1
;
}
}
else
{
*
tag_r
=
(
val
<<
9
)
|
(
oct
<<
2
)
|
tclass
;
val
=
(
val
<<
7
)
|
oct
;
*
tag_r
=
(
val
<<
2
)
|
tclass
;
return
skipped
;
}
}
...
...
@@ -105,7 +106,7 @@ der_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) {
uint8_t
*
buf
=
(
uint8_t
*
)
bufp
;
uint8_t
*
end
;
size_t
required_size
;
in
t
i
;
size_
t
i
;
if
(
tval
<=
30
)
{
/* Encoded in 1 octet */
...
...
@@ -119,8 +120,8 @@ der_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) {
/*
* Compute the size of the subsequent bytes.
*/
for
(
required_size
=
1
,
i
=
7
;
i
<
8
*
sizeof
(
t
ag
);
i
+=
7
)
{
if
(
t
ag
>>
i
)
for
(
required_size
=
1
,
i
=
7
;
i
<
8
*
sizeof
(
t
val
);
i
+=
7
)
{
if
(
t
val
>>
i
)
required_size
++
;
else
break
;
...
...
@@ -133,10 +134,9 @@ der_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size) {
* Fill in the buffer, space permitting.
*/
end
=
buf
+
required_size
-
1
;
for
(
i
-=
7
;
buf
<
=
end
;
i
-=
7
,
buf
++
)
{
for
(
i
-=
7
;
buf
<
end
;
i
-=
7
,
buf
++
)
*
buf
=
0x80
|
((
tval
>>
i
)
&
0x7F
);
}
*
end
&=
0x7F
;
/* Clear the last high bit */
*
buf
=
(
tval
&
0x7F
);
/* Last octet without high bit */
return
required_size
+
1
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment