Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ITS - Intelligent Transport Systems
ITS
Commits
f8693810
Commit
f8693810
authored
Nov 22, 2019
by
Denis Filatov
Browse files
fix cert view
parent
48f475bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/itscertgen/asn1certgen/asn1certgen.c
View file @
f8693810
...
...
@@ -222,6 +222,22 @@ static asn_enc_rval_t Signature_oer_encoder(const asn_TYPE_descriptor_t *td,
return
asn_OP_CHOICE
.
oer_encoder
(
td
,
constraints
,
sptr
,
cb
,
app_key
);
}
static
asn_dec_rval_t
PublicVerificationKey_oer_decoder
(
const
struct
asn_codec_ctx_s
*
opt_codec_ctx
,
const
struct
asn_TYPE_descriptor_s
*
td
,
const
asn_oer_constraints_t
*
constraints
,
void
**
struct_ptr
,
const
void
*
buf_ptr
,
size_t
size
)
{
return
asn_OP_CHOICE
.
oer_decoder
(
opt_codec_ctx
,
td
,
constraints
,
struct_ptr
,
buf_ptr
,
size
);
}
static
asn_dec_rval_t
ServiceSpecificPermissions_oer_decoder
(
const
struct
asn_codec_ctx_s
*
opt_codec_ctx
,
const
struct
asn_TYPE_descriptor_s
*
td
,
const
asn_oer_constraints_t
*
constraints
,
void
**
struct_ptr
,
const
void
*
buf_ptr
,
size_t
size
)
{
return
asn_OP_CHOICE
.
oer_decoder
(
opt_codec_ctx
,
td
,
constraints
,
struct_ptr
,
buf_ptr
,
size
);
}
int
main
(
int
argc
,
char
**
argv
)
{
// set default time to the begining of this year
...
...
@@ -275,22 +291,6 @@ int main(int argc, char ** argv)
asn_dec_rval_t
rc_d
;
asn_enc_rval_t
rc_e
;
if
(
_view
)
{
rc_d
=
asn_decode
(
NULL
,
ATS_BASIC_OER
,
&
asn_DEF_EtsiTs103097Certificate
,
(
void
**
)
&
cert
,
buf
,
ebuf
-
buf
);
if
(
rc_d
.
code
!=
RC_OK
){
fprintf
(
stderr
,
"%s: failed to load at position %d
\n
%.30s
\n
"
,
argv
[
1
],
(
int
)
rc_d
.
consumed
,
buf
+
rc_d
.
consumed
);
return
-
1
;
}
rc_e
=
asn_encode_to_buffer
(
NULL
,
_xer
?
ATS_CANONICAL_XER
:
ATS_NONSTANDARD_PLAINTEXT
,
&
asn_DEF_EtsiTs103097Certificate
,
cert
,
buf
,
CERT_MAX_SIZE
);
if
(
rc_e
.
encoded
<
0
){
fprintf
(
stderr
,
"%s: %s encoding failed for %s
\n
"
,
argv
[
1
],
_xer
?
"XER"
:
"text"
,
rc_e
.
failed_type
->
name
);
return
-
1
;
}
fwrite
(
buf
,
1
,
rc_e
.
encoded
,
stdout
);
return
0
;
}
asn_TYPE_operation_t
issuerOps
=
*
asn_DEF_IssuerIdentifier
.
op
;
asn_DEF_IssuerIdentifier
.
op
=
&
issuerOps
;
...
...
@@ -303,10 +303,52 @@ int main(int argc, char ** argv)
asn_TYPE_operation_t
countryOnlyOps
=
*
asn_DEF_CountryOnly
.
op
;
asn_DEF_CountryOnly
.
op
=
&
countryOnlyOps
;
asn_TYPE_operation_t
publicVerificationKeyOps
=
*
asn_DEF_PublicVerificationKey
.
op
;
asn_DEF_PublicVerificationKey
.
op
=
&
publicVerificationKeyOps
;
asn_TYPE_operation_t
serviceSpecificPermissionsOps
=
*
asn_DEF_ServiceSpecificPermissions
.
op
;
asn_DEF_ServiceSpecificPermissions
.
op
=
&
serviceSpecificPermissionsOps
;
issuerOps
.
xer_decoder
=
IssuerIdentifier_xer_decoder
;
tbsOps
.
oer_encoder
=
ToBeSignedCertificate_oer_encoder
;
signatureOps
.
oer_encoder
=
Signature_oer_encoder
;
countryOnlyOps
.
xer_decoder
=
CountryOnly_xer_decoder
;
publicVerificationKeyOps
.
oer_decoder
=
PublicVerificationKey_oer_decoder
;
serviceSpecificPermissionsOps
.
oer_decoder
=
ServiceSpecificPermissions_oer_decoder
;
if
(
_view
)
{
char
hash
[
50
],
hash_hex
[
256
];
size_t
hLen
;
rc_d
=
asn_decode
(
NULL
,
ATS_BASIC_OER
,
&
asn_DEF_EtsiTs103097Certificate
,
(
void
**
)
&
cert
,
buf
,
ebuf
-
buf
);
if
(
rc_d
.
code
!=
RC_OK
){
fprintf
(
stderr
,
"%s: failed to load at position %d
\n
%.30s
\n
"
,
argv
[
1
],
(
int
)
rc_d
.
consumed
,
buf
+
rc_d
.
consumed
);
return
-
1
;
}
if
(
!
_xer
){
if
(
cert
->
toBeSigned
.
verifyKeyIndicator
.
present
==
VerificationKeyIndicator_PR_verificationKey
&&
cert
->
toBeSigned
.
verifyKeyIndicator
.
choice
.
verificationKey
.
present
==
PublicVerificationKey_PR_ecdsaBrainpoolP384r1
)
{
hLen
=
48
;
sha384_calculate
(
hash
,
(
const
char
*
)
buf
,
rc_d
.
consumed
);
}
else
{
hLen
=
32
;
sha256_calculate
(
hash
,
(
const
char
*
)
buf
,
rc_d
.
consumed
);
}
*
_bin2hex
(
hash_hex
,
sizeof
(
hash_hex
),
hash
,
hLen
)
=
0
;
}
rc_e
=
asn_encode_to_buffer
(
NULL
,
_xer
?
ATS_CANONICAL_XER
:
ATS_NONSTANDARD_PLAINTEXT
,
&
asn_DEF_EtsiTs103097Certificate
,
cert
,
buf
,
CERT_MAX_SIZE
);
if
(
rc_e
.
encoded
<
0
){
fprintf
(
stderr
,
"%s: %s encoding failed for %s
\n
"
,
argv
[
1
],
_xer
?
"XER"
:
"text"
,
rc_e
.
failed_type
->
name
);
return
-
1
;
}
if
(
!
_xer
){
fprintf
(
stderr
,
"Hash : %s
\n
"
,
hash_hex
);
fprintf
(
stderr
,
"Digest: %s
\n
"
,
hash_hex
+
(
hLen
-
8
)
*
2
);
}
fwrite
(
buf
,
1
,
rc_e
.
encoded
,
stdout
);
return
0
;
}
PublicVerificationKey_PR
hashType
=
PublicVerificationKey_PR_NOTHING
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment