Loading tools/itscertgen/asn1certgen/asn1certgen.c +8 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ static int _no_gen = 0; static const char * _cfgFile = NULL; static int _debug = 0; static int _xer = 0; static int _view = 0; static const char _sha256_emptyString[] = { 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, Loading Loading @@ -74,6 +75,7 @@ static copt_t _options [] = { { "n", "name", COPT_STR, (void*)&_certName, "Certificate name (take from profile by default)" }, { "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]" }, { "v", "view", COPT_BOOL, (void*)&_view, "View OER certificate [false]" }, { "x", "oxer", COPT_BOOL, (void*)&_xer, "Decode OER certificate to XER [false]" }, { NULL, NULL, COPT_END, NULL, NULL } }; Loading Loading @@ -239,6 +241,7 @@ int main(int argc, char ** argv) if (_searchPath == NULL) _searchPath = _outPath; if (_keyPath == NULL) _keyPath = _outPath; if(_xer) _view = 1; _outKeyFormat = copts_enum_value(_options, 3, _key_formats); Loading @@ -264,7 +267,7 @@ int main(int argc, char ** argv) ebuf = cstrnload(buf, CERT_MAX_SIZE, argv[1]); if(ebuf == NULL){ fprintf(stderr, "%s: Certificate%s not found\n", argv[1], _xer?"":" profile"); fprintf(stderr, "%s: Certificate%s not found\n", argv[1], (_view)?"":" profile"); return -1; } Loading @@ -272,15 +275,16 @@ int main(int argc, char ** argv) asn_dec_rval_t rc_d; asn_enc_rval_t rc_e; if(_xer) { 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, ATS_CANONICAL_XER, &asn_DEF_EtsiTs103097Certificate, cert, buf, CERT_MAX_SIZE); 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: XER encoding failed for %s\n", argv[1], rc_e.failed_type->name); 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); Loading tools/itscertgen/asn1certgen/asn1keygen.c 0 → 100755 +86 −0 Original line number Diff line number Diff line /********************************************************************* ###################################################################### ## ## 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 _certCount = 1; static ecc_format _outFormat = 0; static ecc_curve_id _curve = 0; static const char * _o_formats[] = { "bin", "hex", "pem", NULL }; static const char * _o_curves[] = { "nist256", "bpool256", "bpool384", NULL }; static char * _keyname = "key"; 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]" }, { "c", "curve", COPT_STRENUM, (void*)_o_curves, "Curve to be used (nist256|bpool256|bpool384)[nist256 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, "<keyname>"); return -1; } _outFormat = copts_enum_value(options, 2, _o_formats); _curve = copts_enum_value(options, 3, _o_curves); if (argc == 1){ argc = 2; argv[1] = _keyname; } if(0 == ecc_api_init()){ char s[1024], *path; size_t len; path = cvstrncpy(s, sizeof(s), _outPath, "/", NULL); len = s+sizeof(s)-path; for (int i = 1; i < argc; i++){ const char * keyname = argv[i]; for (int count = 0; count < _certCount; count++){ void * key = ecc_key_gen(_curve); if (key){ char * e; if (_certCount = 1) e = cstrncpy(path, len, keyname); else e = path + sprintf(path, "%s_%03d", keyname, count + 1); cstrncpy(e, len - (e - path), ".vkey"); ecc_key_private_save(key, s, _outFormat); cstrncpy(e, len - (e - path), "_pub.vkey"); ecc_key_public_save(key, s, _outFormat); ecc_key_free(key); } } } } ecc_api_done(); return 0; } tools/itscertgen/asn1certgen/asn1keygen.vcxproj 0 → 100755 +180 −0 Original line number Diff line number Diff line <?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="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <ItemGroup> <ClCompile Include="ecc_openssl.c" /> <ClCompile Include="applink.c" /> <ClCompile Include="asn1keygen.c" /> </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> <ItemGroup> <ClInclude Include="ecc_api.h" /> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}</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)'=='Debug|x64'" 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> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" 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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <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> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <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>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)</OutDir> <IntDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\$(ProjectName)</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <LinkIncremental>true</LinkIncremental> <OutDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\</OutDir> <IntDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <LinkIncremental>false</LinkIncremental> <OutDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)</OutDir> <IntDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\$(ProjectName)</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <LinkIncremental>false</LinkIncremental> <OutDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\</OutDir> <IntDir>$(ProjectDir)..\build\msvc\$(Platform)\$(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)'=='Debug|x64'"> <ClCompile> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>C:\OpenSSL\Win64\include;..</AdditionalIncludeDirectories> </ClCompile> <Link> <SubSystem>Console</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <AdditionalLibraryDirectories>C:\OpenSSL\Win64\lib\VC</AdditionalLibraryDirectories> <AdditionalDependencies>libcrypto64MDd.lib;libssl64MDd.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> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <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\Win64\include;..</AdditionalIncludeDirectories> </ClCompile> <Link> <SubSystem>Console</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> <AdditionalDependencies>libcrypto64MDd.lib;libssl64MDd.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalLibraryDirectories>C:\OpenSSL\Win64\lib\VC</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> </Project> No newline at end of file tools/itscertgen/asn1certgen/ecc_openssl.c +1 −1 Original line number Diff line number Diff line Loading @@ -356,7 +356,7 @@ void * ecc_key_public_load(const char* path, ecc_curve_id pk_alg) EC_KEY * eckey = NULL; FILE * f = fopen(path, "rb"); EC_POINT * point = NULL; const EC_GROUP * group = _curves[0]; const EC_GROUP * group = _curves[pk_alg]; if (f){ eckey = PEM_read_EC_PUBKEY(f, &eckey, NULL, NULL); if (eckey == NULL){ Loading tools/itscertgen/itscertgen.sln +10 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecc_keygen", "generator\ecc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asn1certgen", "asn1certgen\asn1certgen.vcxproj", "{17B446F1-6962-4B49-8A59-4584807F9024}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asn1keygen", "asn1certgen\asn1keygen.vcxproj", "{6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Loading Loading @@ -85,6 +87,14 @@ Global {17B446F1-6962-4B49-8A59-4584807F9024}.Release|Win32.Build.0 = Release|Win32 {17B446F1-6962-4B49-8A59-4584807F9024}.Release|x64.ActiveCfg = Release|x64 {17B446F1-6962-4B49-8A59-4584807F9024}.Release|x64.Build.0 = Release|x64 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Debug|Win32.ActiveCfg = Debug|Win32 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Debug|Win32.Build.0 = Debug|Win32 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Debug|x64.ActiveCfg = Debug|x64 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Debug|x64.Build.0 = Debug|x64 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Release|Win32.ActiveCfg = Release|Win32 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Release|Win32.Build.0 = Release|Win32 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Release|x64.ActiveCfg = Release|x64 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Loading Loading
tools/itscertgen/asn1certgen/asn1certgen.c +8 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ static int _no_gen = 0; static const char * _cfgFile = NULL; static int _debug = 0; static int _xer = 0; static int _view = 0; static const char _sha256_emptyString[] = { 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, Loading Loading @@ -74,6 +75,7 @@ static copt_t _options [] = { { "n", "name", COPT_STR, (void*)&_certName, "Certificate name (take from profile by default)" }, { "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]" }, { "v", "view", COPT_BOOL, (void*)&_view, "View OER certificate [false]" }, { "x", "oxer", COPT_BOOL, (void*)&_xer, "Decode OER certificate to XER [false]" }, { NULL, NULL, COPT_END, NULL, NULL } }; Loading Loading @@ -239,6 +241,7 @@ int main(int argc, char ** argv) if (_searchPath == NULL) _searchPath = _outPath; if (_keyPath == NULL) _keyPath = _outPath; if(_xer) _view = 1; _outKeyFormat = copts_enum_value(_options, 3, _key_formats); Loading @@ -264,7 +267,7 @@ int main(int argc, char ** argv) ebuf = cstrnload(buf, CERT_MAX_SIZE, argv[1]); if(ebuf == NULL){ fprintf(stderr, "%s: Certificate%s not found\n", argv[1], _xer?"":" profile"); fprintf(stderr, "%s: Certificate%s not found\n", argv[1], (_view)?"":" profile"); return -1; } Loading @@ -272,15 +275,16 @@ int main(int argc, char ** argv) asn_dec_rval_t rc_d; asn_enc_rval_t rc_e; if(_xer) { 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, ATS_CANONICAL_XER, &asn_DEF_EtsiTs103097Certificate, cert, buf, CERT_MAX_SIZE); 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: XER encoding failed for %s\n", argv[1], rc_e.failed_type->name); 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); Loading
tools/itscertgen/asn1certgen/asn1keygen.c 0 → 100755 +86 −0 Original line number Diff line number Diff line /********************************************************************* ###################################################################### ## ## 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 _certCount = 1; static ecc_format _outFormat = 0; static ecc_curve_id _curve = 0; static const char * _o_formats[] = { "bin", "hex", "pem", NULL }; static const char * _o_curves[] = { "nist256", "bpool256", "bpool384", NULL }; static char * _keyname = "key"; 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]" }, { "c", "curve", COPT_STRENUM, (void*)_o_curves, "Curve to be used (nist256|bpool256|bpool384)[nist256 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, "<keyname>"); return -1; } _outFormat = copts_enum_value(options, 2, _o_formats); _curve = copts_enum_value(options, 3, _o_curves); if (argc == 1){ argc = 2; argv[1] = _keyname; } if(0 == ecc_api_init()){ char s[1024], *path; size_t len; path = cvstrncpy(s, sizeof(s), _outPath, "/", NULL); len = s+sizeof(s)-path; for (int i = 1; i < argc; i++){ const char * keyname = argv[i]; for (int count = 0; count < _certCount; count++){ void * key = ecc_key_gen(_curve); if (key){ char * e; if (_certCount = 1) e = cstrncpy(path, len, keyname); else e = path + sprintf(path, "%s_%03d", keyname, count + 1); cstrncpy(e, len - (e - path), ".vkey"); ecc_key_private_save(key, s, _outFormat); cstrncpy(e, len - (e - path), "_pub.vkey"); ecc_key_public_save(key, s, _outFormat); ecc_key_free(key); } } } } ecc_api_done(); return 0; }
tools/itscertgen/asn1certgen/asn1keygen.vcxproj 0 → 100755 +180 −0 Original line number Diff line number Diff line <?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="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <ItemGroup> <ClCompile Include="ecc_openssl.c" /> <ClCompile Include="applink.c" /> <ClCompile Include="asn1keygen.c" /> </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> <ItemGroup> <ClInclude Include="ecc_api.h" /> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}</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)'=='Debug|x64'" 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> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" 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 Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <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> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <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>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)</OutDir> <IntDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\$(ProjectName)</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <LinkIncremental>true</LinkIncremental> <OutDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\</OutDir> <IntDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <LinkIncremental>false</LinkIncremental> <OutDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)</OutDir> <IntDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\$(ProjectName)</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <LinkIncremental>false</LinkIncremental> <OutDir>$(ProjectDir)..\build\msvc\$(Platform)\$(Configuration)\</OutDir> <IntDir>$(ProjectDir)..\build\msvc\$(Platform)\$(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)'=='Debug|x64'"> <ClCompile> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>C:\OpenSSL\Win64\include;..</AdditionalIncludeDirectories> </ClCompile> <Link> <SubSystem>Console</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <AdditionalLibraryDirectories>C:\OpenSSL\Win64\lib\VC</AdditionalLibraryDirectories> <AdditionalDependencies>libcrypto64MDd.lib;libssl64MDd.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> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <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\Win64\include;..</AdditionalIncludeDirectories> </ClCompile> <Link> <SubSystem>Console</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> <AdditionalDependencies>libcrypto64MDd.lib;libssl64MDd.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalLibraryDirectories>C:\OpenSSL\Win64\lib\VC</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> </Project> No newline at end of file
tools/itscertgen/asn1certgen/ecc_openssl.c +1 −1 Original line number Diff line number Diff line Loading @@ -356,7 +356,7 @@ void * ecc_key_public_load(const char* path, ecc_curve_id pk_alg) EC_KEY * eckey = NULL; FILE * f = fopen(path, "rb"); EC_POINT * point = NULL; const EC_GROUP * group = _curves[0]; const EC_GROUP * group = _curves[pk_alg]; if (f){ eckey = PEM_read_EC_PUBKEY(f, &eckey, NULL, NULL); if (eckey == NULL){ Loading
tools/itscertgen/itscertgen.sln +10 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecc_keygen", "generator\ecc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asn1certgen", "asn1certgen\asn1certgen.vcxproj", "{17B446F1-6962-4B49-8A59-4584807F9024}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asn1keygen", "asn1certgen\asn1keygen.vcxproj", "{6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Loading Loading @@ -85,6 +87,14 @@ Global {17B446F1-6962-4B49-8A59-4584807F9024}.Release|Win32.Build.0 = Release|Win32 {17B446F1-6962-4B49-8A59-4584807F9024}.Release|x64.ActiveCfg = Release|x64 {17B446F1-6962-4B49-8A59-4584807F9024}.Release|x64.Build.0 = Release|x64 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Debug|Win32.ActiveCfg = Debug|Win32 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Debug|Win32.Build.0 = Debug|Win32 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Debug|x64.ActiveCfg = Debug|x64 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Debug|x64.Build.0 = Debug|x64 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Release|Win32.ActiveCfg = Release|Win32 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Release|Win32.Build.0 = Release|Win32 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Release|x64.ActiveCfg = Release|x64 {6F0ADC20-E8C3-4996-9E46-F7D5D4FA4BF3}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Loading