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
f7110ebe
Commit
f7110ebe
authored
Sep 12, 2018
by
Denis Filatov
Browse files
add oer->xer mode in asn1certgen; fix warnings
parent
03221d5a
Changes
5
Hide whitespace changes
Inline
Side-by-side
tools/itscertgen/asn1certgen/asn1certgen.c
View file @
f7110ebe
...
...
@@ -23,6 +23,7 @@ static const char * _keyPath = NULL;
static
int
_force
=
0
;
static
const
char
*
_cfgFile
=
NULL
;
static
int
_debug
=
0
;
static
int
_xer
=
0
;
static
const
char
_sha256_emptyString
[]
=
{
0xe3
,
0xb0
,
0xc4
,
0x42
,
0x98
,
0xfc
,
0x1c
,
0x14
,
0x9a
,
0xfb
,
0xf4
,
0xc8
,
0x99
,
0x6f
,
0xb9
,
0x24
,
...
...
@@ -75,6 +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]"
},
{
NULL
,
NULL
,
COPT_END
,
NULL
,
NULL
}
};
...
...
@@ -264,13 +266,28 @@ int main(int argc, char ** argv)
ebuf
=
cstrnload
(
buf
,
CERT_MAX_SIZE
,
argv
[
1
]);
if
(
ebuf
==
NULL
){
fprintf
(
stderr
,
"%s: Certificate
profile
not found
\n
"
,
argv
[
1
]);
fprintf
(
stderr
,
"%s: Certificate
%s
not found
\n
"
,
argv
[
1
]
,
_xer
?
""
:
" profile"
);
return
-
1
;
}
FILE
*
f
;
asn_dec_rval_t
rc_d
;
asn_enc_rval_t
rc_e
;
if
(
_xer
)
{
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
,
ATS_CANONICAL_XER
,
&
asn_DEF_EtsiTs103097Certificate
,
cert
,
buf
,
CERT_MAX_SIZE
);
if
(
rc_e
.
encoded
<
0
){
fprintf
(
stderr
,
"%s: XER encoding failed for %s
\n
"
,
argv
[
1
],
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
;
...
...
tools/itscertgen/asn1certgen/asn1certgen.vcxproj
View file @
f7110ebe
...
...
@@ -536,7 +536,7 @@
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
WIN32;random=rand;_USE_MATH_DEFINES;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<PreprocessorDefinitions>
WIN32;random=rand;_USE_MATH_DEFINES;_
CRT_SECURE_NO_WARNINGS;_
DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
C:\OpenSSL\Win64\include;..;asncodec
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
...
...
tools/itscertgen/asn1certgen/asn1certgen.xslt
View file @
f7110ebe
...
...
@@ -88,12 +88,12 @@
<xsl:template
match =
"subject"
>
<xsl:variable
name=
"eeType"
>
<xsl:choose>
<xsl:when
test=
"@type = 'ROOT'"
>
A
0
</xsl:when>
<xsl:when
test=
"@type = 'AA'"
>
8
0
</xsl:when>
<xsl:when
test=
"@type = 'AT'"
>
8
0
</xsl:when>
<xsl:when
test=
"@type = 'TLM'"
>
8
0
</xsl:when>
<xsl:when
test=
"@type = 'EA'"
>
8
0
</xsl:when>
<!-- certReqPermissions is not used yet in TS103097 -->
<xsl:when
test=
"@type = 'EC'"
>
8
0
</xsl:when>
<!-- certReqPermissions is not used yet in TS103097 -->
<xsl:when
test=
"@type = 'ROOT'"
>
1100000
0
</xsl:when>
<xsl:when
test=
"@type = 'AA'"
>
1000000
0
</xsl:when>
<xsl:when
test=
"@type = 'AT'"
>
1000000
0
</xsl:when>
<xsl:when
test=
"@type = 'TLM'"
>
1000000
0
</xsl:when>
<xsl:when
test=
"@type = 'EA'"
>
1000000
0
</xsl:when>
<!-- certReqPermissions is not used yet in TS103097 -->
<xsl:when
test=
"@type = 'EC'"
>
1000000
0
</xsl:when>
<!-- certReqPermissions is not used yet in TS103097 -->
<xsl:otherwise>
2
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
...
...
tools/itscertgen/asn1certgen/asncodec/PsidGroupPermissions.c
View file @
f7110ebe
...
...
@@ -52,7 +52,7 @@ static int asn_DFL_4_set_0(void **sptr) {
return
0
;
}
static
int
asn_DFL_5_cmp_0
(
const
void
*
sptr
)
{
const
uint8_t
*
def_buf
[]
=
{
0
};
uint8_t
def_buf
[]
=
{
0
};
BIT_STRING_t
defv
=
{
def_buf
,
1
,
7
};
return
BIT_STRING_compare
(
&
asn_DEF_EndEntityType
,
sptr
,
&
defv
);
}
...
...
tools/itscertgen/asn1certgen/ecc_openssl.c
View file @
f7110ebe
...
...
@@ -7,9 +7,6 @@
## This code is provided under the CeCill-C license agreement.
######################################################################
*********************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include
<openssl/evp.h>
#include
<openssl/err.h>
#include
<openssl/ec.h>
...
...
@@ -191,7 +188,7 @@ int ecc_key_private_save(void* key, const char* path, ecc_format format)
ecbn
=
EC_KEY_get0_private_key
(
eckey
);
if
(
ecbn
){
int
bnlen
=
BN_num_bytes
(
ecbn
);
in
t
len
=
(
bnlen
<
fsize
)
?
fsize
:
bnlen
;
size_
t
len
=
(
bnlen
<
fsize
)
?
fsize
:
bnlen
;
char
*
buf
=
(
char
*
)
OPENSSL_malloc
(
len
*
2
+
1
);
if
(
bnlen
<
len
)
memset
(
buf
,
0
,
len
-
bnlen
);
BN_bn2bin
(
ecbn
,
(
unsigned
char
*
)(
buf
+
len
-
bnlen
));
...
...
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