Commit 1f88debd authored by filatov's avatar filatov

Certificate generator updates

parent 8a3e80ed
......@@ -49,7 +49,8 @@ typedef enum {
si_digest,
si_certificate,
si_certificate_chain,
si_digest_with_other_algorithm
si_digest_with_other_algorithm,
si_other
} SignerInfoType;
typedef enum {
......@@ -117,7 +118,8 @@ static const char * _signer_types[] = {
"self",
"digest",
"certificate",
"chain",
"certificate_chain",
"other_digest",
"other",
};
......@@ -252,19 +254,34 @@ int main(int argc, char ** argv)
cxml_handler_add_default_entities(NULL);
if (*p > 1){
fprintf(stderr, "Unsupported signer type: %s\n", ENUMSTRING(*p, _signer_types));
return -1;
}
fprintf(stdout, "\t<signer type =\"%s\"", ENUMSTRING(*p, _signer_types));
if (*p == 1){
if (*p == si_digest || *p == si_digest_with_other_algorithm){
if (*p == si_digest_with_other_algorithm){
p++;
fprintf(stdout, " algorithm =\"%s\"", ENUMSTRING(*p, _pk_algorithms));
}
p++;
fprintf(stdout, " digest=\"");
print_x(stdout, p + 1, 8);
print_x(stdout, p, 8);
fprintf(stdout, "\"");
p += 8;
fprintf(stdout, "/>\n");
}
else{
fprintf(stdout, ">\n");
if (*p == si_certificate_chain || *p >= si_other){
const char * b = ++p;
length = (uint32_t)cintx_read(&p, e, NULL);
print_x(stdout, b, length);
p += length;
}
else{
fprintf(stderr, "Unsupported signer type: %d\n", ENUMSTRING(*p, _signer_types));
return -1;
}
fprintf(stdout, "\t</signer>\n");
}
fprintf(stdout, "/>\n");
p++;
const SubjectInfo * si = (const SubjectInfo *)p;
if (si->subject_type > crl_signer){
fprintf(stderr, "Unsupported subject type: %d\n", si->subject_type);
......@@ -736,6 +753,15 @@ static int print_validity(const char ** pp, const char * e)
}
}
break;
default:
{
fprintf(stdout, "\t\t\t<region type=\"%d\">\n", rtype);
int size = (int)cintx_read(&p, e, &rc);
print_x(stdout, p, size); p += size;
fprintf(stdout, "\n\t\t\t</region>\n");
}
break;
}
}
fprintf(stdout, "\t\t</restriction>\n");
......
......@@ -36,14 +36,14 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<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>Unicode</CharacterSet>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
......@@ -72,12 +72,12 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\OpenSSL-Win32\include;..</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\OpenSSL\Win32\include;..</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\OpenSSL-Win32\lib\VC\static</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\OpenSSL\Win32\lib\VC\static</AdditionalLibraryDirectories>
<AdditionalDependencies>libeay32MDd.lib;ssleay32MDd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
......@@ -90,14 +90,14 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\OpenSSL-Win32\include;..</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\OpenSSL\Win32\include;..</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>C:\OpenSSL-Win32\lib\VC\static</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\OpenSSL\Win32\lib\VC\static</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
This diff is collapsed.
/* lib/mkgmtime.h
Copyright (C) 2010 DeSmuME team
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MKGMTIME_H_
#define _MKGMTIME_H_
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
extern time_t mkgmtime(struct tm *tim_p);
extern time_t mktaitime(struct tm *tim_p);
extern time_t addleapseconds(time_t t);
#define mktaitime32(X) ((unsigned long)mktaitime(X))
extern unsigned long mkitstime32(struct tm *tim_p);
extern unsigned long unix2itstime32(time_t t);
extern unsigned long long mktaitime64(struct tm *tim_p);
extern unsigned long long mkitstime64(struct tm *tim_p);
extern unsigned long long unix2itstime64(time_t t);
extern const char * stritsdate32(time_t t);
extern const char * strtaidate(time_t t);
extern const char * strgmtdate(time_t t);
#ifdef __cplusplus
}
#endif
#endif
//_MKGMTIME_H_
......@@ -35,6 +35,22 @@ int cstrequal(const char * s1, const char * s2)
return (s1 == s2) || (s1 && s2 && 0 == strcmp(s1, s2));
}
char* cstrisprefix(const char * str, const char * prefix)
{
int len;
if (str == prefix){
return (char*)(str ? str + strlen(str) : NULL);
}
if (str == NULL || prefix == NULL || 0 == *prefix){
return (char*)str;
}
len = strlen(prefix);
if (0 == memcmp(str, prefix, len)){
return ((char*)str) + len;
}
return NULL;
}
char * cstrcpy(char * dst, const char * src)
{
if(!dst) return (char*)0;
......@@ -52,22 +68,37 @@ char * cstrcpy(char * dst, const char * src)
/* copy up to maxsize characters from src to dst and return pointer to the next byte after the end */
char * cstrncpy(char * dst, int maxsize, const char * src)
{
if(!dst) return (char*)0;
if (!dst) return (char*)0;
unsigned int ms = maxsize;
unsigned int len = 0;
if(src && ms > 0){
if (src && ms > 0){
len = strlen(src);
if (len > ms){
len = ms;
}
if(len){
if (len){
memcpy(dst, src, len);
}
}
dst[len]=0;
dst[len] = 0;
return dst + len;
}
char * cmemcpy(char * dst, const char * src, int length)
{
if (!dst) return (char*)0;
if (length){
if (src){
memcpy(dst, src, length);
}
else{
memset(dst, 0, length);
}
}
dst[length] = 0;
return dst + length;
}
/* copy up to maxsize characters from src to dst and return pointer to the next byte after the end */
char * cvstrncpy(char * dst, int maxsize, const char * ptr, ...)
{
......
......@@ -17,9 +17,11 @@ extern "C" {
#define cisspace(X) isspace((int)(X))
#define cisdigit(X) isdigit((int)(X))
#define cisalnum(X) isalnum((int)(X))
int cstrlen(const char * str);
int cstrnlen(const char * str, int maxsize);
/* return pointer to the end of line*/
char* cstrend(const char * str);
/* copy src to dst and return pointer to the next byte after the end */
char * cstrcpy(char * dst, const char * src);
......@@ -27,10 +29,15 @@ char * cstrcpy(char * dst, const char * src);
/* copy up to maxsize characters from src to dst and return pointer to the next byte after the end */
char * cstrncpy(char * dst, int maxsize, const char * src);
/* copy length characters from src to dst or fill dst by zero if src is null and return pointer to the next byte after the end*/
char * cmemcpy(char * dst, const char * src, int length);
/* copy up to maxsize characters from parameters to dst and return pointer to the next byte after the end */
char * cvstrncpy(char * dst, int maxsize, const char * ptr, ...);
/* return nonzero if strings are equals*/
int cstrequal(const char * s1, const char * s2);
char* cstrisprefix(const char * str, const char * prefix);
/* allocate copy of the str */
char * cstralloc(int size);
......
......@@ -31,14 +31,14 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
......
This diff is collapsed.
......@@ -40,14 +40,14 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<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>Unicode</CharacterSet>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
......@@ -74,12 +74,12 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\OpenSSL-Win32\include;..</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\OpenSSL\Win32\include;..</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\OpenSSL-Win32\lib\VC\static</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\OpenSSL\Win32\lib\VC\static</AdditionalLibraryDirectories>
<AdditionalDependencies>libeay32MDd.lib;ssleay32MDd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
......@@ -92,12 +92,15 @@
<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" />
......
......@@ -28,14 +28,14 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<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>Unicode</CharacterSet>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment