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
1489a789
Commit
1489a789
authored
Sep 14, 2018
by
Denis Filatov
Browse files
fix usage of pre-defined public keys for certificate
parent
92b5df85
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/itscertgen/asn1certgen/asn1certgen.c
View file @
1489a789
...
...
@@ -76,7 +76,7 @@ static copt_t _options [] = {
{
"e"
,
"ekey"
,
COPT_STR
,
(
void
*
)
&
_decriptionKey
,
"Encription public key (generate key pair if neccessary)"
},
{
"s"
,
"signer"
,
COPT_STR
,
(
void
*
)
&
_signerName
,
"Signer certificate name [take from profile by default]"
},
{
"D"
,
"debug"
,
COPT_BOOL
,
(
void
*
)
&
_debug
,
"Dump hashes and other values [false]"
},
{
"x"
,
"oxer"
,
COPT_BOOL
,
(
void
*
)
&
_xer
,
"Decode OER certificate to XER [false]"
},
{
"x"
,
"oxer"
,
COPT_BOOL
,
(
void
*
)
&
_xer
,
"Decode OER certificate to XER [false]"
},
{
NULL
,
NULL
,
COPT_END
,
NULL
,
NULL
}
};
...
...
@@ -404,9 +404,6 @@ int main(int argc, char ** argv)
// generate keys if necessary
// buf = name of private key file
cvstrncpy
(
buf
,
CERT_MAX_SIZE
,
_keyPath
,
"/"
,
_profileName
,
EXT_VKEY
,
NULL
);
if
(
_force
){
remove
(
buf
);
}
switch
(
cert
->
toBeSigned
.
verifyKeyIndicator
.
present
){
case
VerificationKeyIndicator_PR_verificationKey
:
switch
(
cert
->
toBeSigned
.
verifyKeyIndicator
.
choice
.
verificationKey
.
present
){
...
...
@@ -434,9 +431,6 @@ int main(int argc, char ** argv)
}
if
(
cert
->
toBeSigned
.
encryptionKey
){
cvstrncpy
(
buf
,
CERT_MAX_SIZE
,
_keyPath
,
"/"
,
_profileName
,
EXT_EKEY
,
NULL
);
if
(
_force
){
remove
(
buf
);
}
switch
(
cert
->
toBeSigned
.
encryptionKey
->
publicKey
.
present
){
case
BasePublicEncryptionKey_PR_NOTHING
:
cert
->
toBeSigned
.
encryptionKey
->
publicKey
.
present
=
BasePublicEncryptionKey_PR_eciesNistP256
;
...
...
@@ -496,19 +490,37 @@ static void fill_curve_point_eccP256(EccP256CurvePoint_t* point, ecc_curve_id cu
static
void
fill_curve_point_eccP384
(
EccP384CurvePoint_t
*
point
,
ecc_curve_id
curveType
,
char
*
keyPath
)
{
void
*
key
;
void
*
key
=
NULL
;
char
x
[
48
],
y
[
48
];
int
compressed_y
;
int
fsize
;
key
=
ecc_key_private_load
(
keyPath
,
curveType
);
char
*
e_pub
=
keyPath
+
strlen
(
keyPath
);
if
(
!
_force
){
// check for public key
strcpy
(
e_pub
,
EXT_PUB
);
key
=
ecc_key_public_load
(
keyPath
,
curveType
);
if
(
_debug
&&
key
){
fprintf
(
stderr
,
"DEBUG: use pre-generated key %s
\n
"
,
keyPath
);
}
*
e_pub
=
0
;
}
else
{
remove
(
keyPath
);
}
if
(
key
==
NULL
){
if
(
_debug
){
fprintf
(
stderr
,
"DEBUG: generate key %s
\n
"
,
keyPath
);
key
=
ecc_key_private_load
(
keyPath
,
curveType
);
if
(
key
==
NULL
){
if
(
_debug
){
fprintf
(
stderr
,
"DEBUG: generate key %s
\n
"
,
keyPath
);
}
key
=
ecc_key_gen
(
curveType
);
ecc_key_private_save
(
key
,
keyPath
,
_outKeyFormat
);
strcpy
(
e_pub
,
EXT_PUB
);
ecc_key_public_save
(
key
,
keyPath
,
_outKeyFormat
);
}
else
{
if
(
_debug
){
fprintf
(
stderr
,
"DEBUG: use pre-generated key %s
\n
"
,
keyPath
);
}
}
key
=
ecc_key_gen
(
curveType
);
ecc_key_private_save
(
key
,
keyPath
,
_outKeyFormat
);
strcat
(
keyPath
,
EXT_PUB
);
ecc_key_public_save
(
key
,
keyPath
,
_outKeyFormat
);
}
fsize
=
ecc_key_public
(
key
,
x
,
y
,
&
compressed_y
);
if
(
fsize
>
0
){
...
...
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