Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ITS - Intelligent Transport Systems
ITS
Commits
f63da6c8
Commit
f63da6c8
authored
Jan 26, 2017
by
filatov
Browse files
add ecc_keygen tool
parent
eeae1809
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
181 additions
and
0 deletions
+181
-0
tools/itscertgen/generator/ecc_keygen.c
tools/itscertgen/generator/ecc_keygen.c
+66
-0
tools/itscertgen/generator/ecc_keygen.vcxproj
tools/itscertgen/generator/ecc_keygen.vcxproj
+109
-0
tools/itscertgen/itscertgen.sln
tools/itscertgen/itscertgen.sln
+6
-0
No files found.
tools/itscertgen/generator/ecc_keygen.c
0 → 100644
View file @
f63da6c8
/*********************************************************************
######################################################################
##
## Created by: Denis Filatov
##
## Copyleft (c) 2015
## This code is provided under the CeCill-C license agreement.
######################################################################
*********************************************************************/
#include "ecc_api.h"
#include <stdio.h>
#include "../cshared/copts.h"
#include "../cshared/cstr.h"
static
const
char
*
_outPath
=
"."
;
static
int
_outFormat
=
0
;
static
int
_certCount
=
1
;
static
int
_compressed
=
0
;
static
const
char
*
_o_formats
[]
=
{
"bin"
,
"hex"
,
"pem"
,
NULL
};
static
copt_t
options
[]
=
{
{
"h?"
,
"help"
,
COPT_HELP
,
NULL
,
"Print this help page"
},
{
"o"
,
"out"
,
COPT_STR
,
(
void
*
)
&
_outPath
,
"Output path [current dir by default]"
},
{
"O"
,
"format"
,
COPT_STRENUM
,
(
void
*
)
_o_formats
,
"Output format (bin|hex|pem)[binary by default]"
},
{
"n"
,
"count"
,
COPT_INT
,
(
void
*
)
&
_certCount
,
"Key pair count (1 by default)"
},
{
NULL
,
NULL
,
COPT_END
,
NULL
,
NULL
}
};
int
main
(
int
argc
,
char
**
argv
)
{
argc
=
coptions
(
argc
,
argv
,
COPT_HELP_NOVALUES
,
options
);
if
(
argc
<
1
){
if
(
argc
<
0
&&
(
0
-
argc
)
<
((
sizeof
(
options
)
/
sizeof
(
options
[
0
]))
-
1
)){
printf
(
"Unknown option %s
\n
"
,
argv
[
0
-
argc
]);
}
const
char
*
a
=
strrchr
(
argv
[
0
],
'/'
);
if
(
a
==
NULL
)
a
=
argv
[
0
];
coptions_help
(
stdout
,
a
,
COPT_HELP_NOVALUES
,
options
,
"<profile> [signer]"
);
return
-
1
;
}
_outFormat
=
copts_enum_value
(
options
,
2
,
_o_formats
);
if
(
0
==
ecc_api_init
()){
char
s
[
1024
],
*
path
;
int
len
;
path
=
cvstrncpy
(
s
,
sizeof
(
s
),
_outPath
,
"/"
,
NULL
);
len
=
s
+
sizeof
(
s
)
-
path
;
for
(
int
count
=
0
;
count
<
_certCount
;
count
++
){
void
*
key
=
ecc_api_key_gen
(
ecdsa_nistp256_with_sha256
,
aes_128_ccm
);
if
(
key
){
int
nlen
=
sprintf
(
path
,
"key_%03d"
,
count
+
1
);
cstrncpy
(
path
+
nlen
,
len
-
nlen
,
".prv"
);
ecc_api_key_private_save
(
key
,
s
,
_outFormat
);
cstrncpy
(
path
+
nlen
,
len
-
nlen
,
".pub"
);
ecc_api_key_public_save
(
key
,
s
,
_outFormat
);
ecc_api_key_free
(
key
);
}
}
}
ecc_api_done
();
return
0
;
}
tools/itscertgen/generator/ecc_keygen.vcxproj
0 → 100644
View file @
f63da6c8
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
ToolsVersion=
"12.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
<Configuration>
Debug
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|Win32"
>
<Configuration>
Release
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"applink.c"
/>
<ClCompile
Include=
"ecc_keygen.c"
/>
<ClCompile
Include=
"ecc_openssl.c"
>
<ExcludedFromBuild
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
false
</ExcludedFromBuild>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"ecc_api.h"
/>
</ItemGroup>
<ItemGroup>
<ProjectReference
Include=
"..\cshared\cshared.vcxproj"
>
<Project>
{d5918b85-fa45-4f75-9b50-c2d3e34aba17}
</Project>
</ProjectReference>
<ProjectReference
Include=
"..\cxml\cxml.vcxproj"
>
<Project>
{cbfc4bfa-fe7e-45fb-ae2f-2608b7c0ad07}
</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<ProjectGuid>
{38CBB245-1E96-4010-8E21-4C58EAA7122A}
</ProjectGuid>
<Keyword>
Win32Proj
</Keyword>
<RootNamespace>
itscertgen
</RootNamespace>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v120
</PlatformToolset>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v120
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<LinkIncremental>
true
</LinkIncremental>
<OutDir>
$(SolutionDir)build\msvc\$(Configuration)\
</OutDir>
<IntDir>
$(SolutionDir)build\msvc\$(Configuration)\$(ProjectName)\
</IntDir>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<LinkIncremental>
false
</LinkIncremental>
<OutDir>
$(SolutionDir)build\msvc\$(Configuration)\
</OutDir>
<IntDir>
$(SolutionDir)build\msvc\$(Configuration)\$(ProjectName)\
</IntDir>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
C:\OpenSSL\Win32\include;..
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<AdditionalLibraryDirectories>
C:\OpenSSL\Win32\lib\VC\static
</AdditionalLibraryDirectories>
<AdditionalDependencies>
libeay32MDd.lib;ssleay32MDd.lib;%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<AdditionalIncludeDirectories>
C:\OpenSSL\Win32\include;..
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<AdditionalDependencies>
libeay32MDd.lib;ssleay32MDd.lib;%(AdditionalDependencies)
</AdditionalDependencies>
<AdditionalLibraryDirectories>
C:\OpenSSL\Win32\lib\VC\static
</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
tools/itscertgen/itscertgen.sln
View file @
f63da6c8
...
...
@@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "itscertinfo", "checker\itsc
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msgcheck", "msgcheck\msgcheck.vcxproj", "{D6D77DDB-032E-4E26-AEC3-7BA9D955D476}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecc_keygen", "generator\ecc_keygen.vcxproj", "{38CBB245-1E96-4010-8E21-4C58EAA7122A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
...
...
@@ -43,6 +45,10 @@ Global
{D6D77DDB-032E-4E26-AEC3-7BA9D955D476}.Debug|Win32.Build.0 = Debug|Win32
{D6D77DDB-032E-4E26-AEC3-7BA9D955D476}.Release|Win32.ActiveCfg = Release|Win32
{D6D77DDB-032E-4E26-AEC3-7BA9D955D476}.Release|Win32.Build.0 = Release|Win32
{38CBB245-1E96-4010-8E21-4C58EAA7122A}.Debug|Win32.ActiveCfg = Debug|Win32
{38CBB245-1E96-4010-8E21-4C58EAA7122A}.Debug|Win32.Build.0 = Debug|Win32
{38CBB245-1E96-4010-8E21-4C58EAA7122A}.Release|Win32.ActiveCfg = Release|Win32
{38CBB245-1E96-4010-8E21-4C58EAA7122A}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
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