-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.cpp
538 lines (489 loc) · 15.8 KB
/
util.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
#include "stdafx.h"
#include "util.h"
#include <string>
#include <objbase.h>
#include <sstream>
#include <vector>
#include <comutil.h>
#include <algorithm>
#include <ShlObj.h>
#include <gdiplus.h>
#pragma comment(lib,"gdiplus.lib")
#include "Definitions.h"
#include "cairo.h"
#include <direct.h>
#include <io.h>
int doubleCmp(double a, double b)
{
const double EPS = 1e-6; //一般这样子就够,但有时具体题目要考虑是否要更小的
if (fabs(a - b) < EPS) //判断是否相等
{
return 0;
}
else if (a > b + EPS)
{
return 1;
}
else{
return -1;
}
}
void CreateDir(const char *dir)
{
int m = 0, n;
std::string str1, str2;
str1 = dir;
str2 = str1.substr(0, 2);
str1 = str1.substr(3, str1.size());
while (m >= 0)
{
m = str1.find('\\');
str2 += '\\' + str1.substr(0, m);
n = _access(str2.c_str(), 0); //判断该目录是否存在
if (n == -1)
{
_mkdir(str2.c_str()); //创建目录
}
str1 = str1.substr(m + 1, str1.size());
}
}
std::string GenerateGUIDString()
{
GUID guid;
CoCreateGuid(&guid);
char buf[64] = { 0 };
sprintf_s(buf, sizeof(buf), "OFD-%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1],
guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5],
guid.Data4[6], guid.Data4[7]);
return std::string(buf);
}
time_t string2time(std::string strTime)
{
tm tm1;
memset(&tm1, 0, sizeof(tm1));
time_t time1;
sscanf_s(strTime.c_str(), "%d-%d-%d %d:%d:%d",
&(tm1.tm_year),
&(tm1.tm_mon),
&(tm1.tm_mday),
&(tm1.tm_hour),
&(tm1.tm_min),
&(tm1.tm_sec));
tm1.tm_year -= 1900;
tm1.tm_mon -= 1;
time1 = mktime(&tm1);
return time1;
}
std::string time2string(time_t time,unsigned long usec)
{
tm tm1;
memset(&tm1, 0, sizeof(tm1));
localtime_s(&tm1, &time);
char tmp[MAX_PATH] = { 0 };
strftime(tmp, MAX_PATH, "%Y%m%d%H%M%S", &tm1);
std::string out(tmp);
out += ".";
char chtmp[4] = { 0 };
ltoa(usec, chtmp, 10);
out += chtmp;
out += "Z";
return out;
}
std::string time2generalizedstring(time_t time)
{
tm tm1;
memset(&tm1, 0, sizeof(tm1));
localtime_s(&tm1, &time);
char tmp[MAX_PATH] = { 0 };
strftime(tmp, MAX_PATH, "%Y-%m-%d %H:%M:%S", &tm1);
return std::string(tmp);
}
void split(const std::string& s, char delimiter, std::vector<std::string> &out)
{
std::string token;
std::istringstream tokenStream(s);
while (std::getline(tokenStream, token, delimiter))
{
out.push_back(token);
}
}
cairo_status_t cairo_read_func_mine(void *closure, unsigned char *data, unsigned int length)
{
auto* pPngData = (st_png_data*)closure;
memcpy(data, pPngData->pdata + pPngData->length, length);
pPngData->length += length;
return CAIRO_STATUS_SUCCESS;
}
cairo_status_t cairo_write_func_mine(void *closure, const unsigned char *data, unsigned int length)
{
auto* pPngData = (st_png_data*)closure;
memcpy(pPngData->pdata + pPngData->length, data, length);
pPngData->length += length;
return CAIRO_STATUS_SUCCESS;
}
inline std::string convertPathToAbsolute(std::string relativePath, std::string baseDir)
{
std::string str = relativePath;
std::replace(str.begin(), str.end(), '/', '\\');
if (PathIsRelative(str.c_str()))
{
char tmp[MAX_PATH] = { 0 };
memcpy(tmp, baseDir.c_str(), baseDir.length());
PathRemoveFileSpecA(tmp);
PathAddBackslash(tmp);
str = std::string(tmp) + str;
}
return str;
}
cairo_surface_t *cairo_image_surface_create_from_jpeg(const char *filename, std::map<cairo_surface_t *, std::pair<Gdiplus::Bitmap *, Gdiplus::BitmapData *>> *mapImage, ULONG_PTR *pGdiplusToken)
{
Gdiplus::GdiplusStartupInput m_gdiplusStartupInput;
Gdiplus::GdiplusStartup(pGdiplusToken, &m_gdiplusStartupInput, NULL);
/* OnPaint显示 jpg图片 */
auto* pImage = new Gdiplus::Bitmap(_com_util::ConvertStringToBSTR(filename));
auto *bitmapData = new Gdiplus::BitmapData();
auto * rect = new Gdiplus::Rect(0, 0, pImage->GetWidth(), pImage->GetHeight());
pImage->LockBits(rect, Gdiplus::ImageLockMode::ImageLockModeRead, PixelFormat32bppARGB, bitmapData);
delete rect;
cairo_surface_t *surface = cairo_image_surface_create_for_data((BYTE *)bitmapData->Scan0, cairo_format_t::CAIRO_FORMAT_ARGB32, pImage->GetWidth(), pImage->GetHeight(), cairo_format_stride_for_width(cairo_format_t::CAIRO_FORMAT_ARGB32, pImage->GetWidth()));
/* 使用完 GDI+函数后, 需要卸载 GDI+, 释放 GDI+使用的资源 */
mapImage->insert(std::make_pair(surface, std::make_pair(pImage, bitmapData)));
return surface;
}
void cairo_image_surface_delete_from_jpeg(cairo_surface_t *surface, std::map<cairo_surface_t *, std::pair<Gdiplus::Bitmap *, Gdiplus::BitmapData *>> *mapImage, ULONG_PTR *pGdiplusToken)
{
delete mapImage->at(surface).first;
delete mapImage->at(surface).second;
mapImage->erase(surface);
if (mapImage->size()==0)
{
Gdiplus::GdiplusShutdown(*pGdiplusToken);
*pGdiplusToken = NULL;
}
}
void cairo_image_surface_delete_from_jbig2(cairo_surface_t *surface, std::map<cairo_surface_t *, std::pair<Gdiplus::Bitmap *, Gdiplus::BitmapData *>> *mapImage)
{
delete mapImage->at(surface).first;
delete mapImage->at(surface).second;
mapImage->erase(surface);
}
cairo_surface_t *cairo_image_surface_create_from_jbig2(const char *filename, int *width, int *height, unsigned char **ptrRememberToFree)
{
FILE *f = nullptr, *f_page = nullptr;
Jbig2Ctx *ctx;
uint8_t buf[1];
ctx = jbig2_ctx_new(nullptr, (Jbig2Options)0,
nullptr,
nullptr, nullptr);
fopen_s(&f, filename, "rb");
if (f == nullptr)
{
TRACE("error opening %s\n", filename);
return nullptr;
}
for (;;)
{
int n_bytes = fread(buf, 1, sizeof(buf), f);
if (n_bytes <= 0)
break;
if (jbig2_data_in(ctx, buf, n_bytes))
break;
}
fclose(f);
jbig2_complete_page(ctx);
Jbig2Image *image;
if ((image = jbig2_page_out(ctx)) != nullptr) {
int newstride = (image->stride % 8 == 0 ? image->stride : (1 + (image->stride / 8)) * 8);
int len = image->height*newstride;
auto *newimage = (BYTE *)malloc(len);
*ptrRememberToFree = newimage;
memset(newimage, 0x00, len);
for (int j = 0; j < image->height; j++)
{
byte *linedata = image->data + image->stride * j;
memcpy(newimage + newstride*j, linedata, image->stride);
for (int i = 0; i < newstride; i++)
{
ReverseBit(newimage + newstride*j+i);
}
}
cairo_surface_t *ret = cairo_image_surface_create_for_data(newimage, cairo_format_t::CAIRO_FORMAT_A1, image->width, image->height, newstride);
cairo_t *tret = cairo_create(ret);
*width = image->width;
*height = image->height;
jbig2_release_page(ctx, image);
jbig2_ctx_free(ctx);
return ret;
}
jbig2_ctx_free(ctx);
return nullptr;
}
void ct_matrix_to_cairo_matrix(CT_Matrix *ct_matrix, cairo_matrix_t *cairo_ctm)
{
cairo_ctm->xx = ct_matrix->xx;
cairo_ctm->xy = ct_matrix->xy;
cairo_ctm->yx = ct_matrix->yx;
cairo_ctm->yy = ct_matrix->yy;
cairo_ctm->x0 = MM2PIXEL(ct_matrix->x0);
cairo_ctm->y0 = MM2PIXEL(ct_matrix->y0);
}
void fnReadCharactersUTF8(const char* pszSentence, std::vector<std::string>& vec)
{
std::string text = pszSentence;
do
{
if (text.length() <= 0)
break;
std::string::const_iterator begin = text.begin();
std::string::const_iterator end = text.end();
while (begin != end)
{
unsigned char c = *begin;
int n = 0;
if ((c & 0x80) == 0)
n = 1;
else if ((c & 0xE0) == 0xC0)
n = 2;
else if ((c & 0xF0) == 0xE0)
n = 3;
else if ((c & 0xF8) == 0xF0)
n = 4;
else if ((c & 0xFC) == 0xF8)
n = 5;
else if ((c & 0xFE) == 0xFC)
n = 6;
else
break;
if (end - begin < n)
break;
std::string substring;
substring += *begin;
bool isError = false;
for (int i = 1; i < n; ++i)
{
if ((begin[i] & 0xC0) != 0x80)
{
isError = true;
break;
}
substring += begin[i];
}
if (isError)
break;
vec.push_back(substring);
begin += n;
}
} while (false);
}
inline std::string UTF82GBK(const char *szUtf8)
{
int n = MultiByteToWideChar(CP_UTF8, 0, szUtf8, -1, nullptr, 0);
auto *wszGBK = new WCHAR[sizeof(WCHAR) * n];
ZeroMemory(wszGBK, sizeof(WCHAR) * n);
MultiByteToWideChar(CP_UTF8, 0, szUtf8, -1, wszGBK, n);
char *ret = _com_util::ConvertBSTRToString(wszGBK);
delete wszGBK;
wszGBK = nullptr;
return ret;
}
void cairo_quadratic_to(cairo_t *cr,double x1, double y1,double x2, double y2)
{
double x0, y0;
cairo_get_current_point(cr, &x0, &y0);
cairo_curve_to(cr,
2.0 / 3.0 * x1 + 1.0 / 3.0 * x0,
2.0 / 3.0 * y1 + 1.0 / 3.0 * y0,
2.0 / 3.0 * x1 + 1.0 / 3.0 * x2,
2.0 / 3.0 * y1 + 1.0 / 3.0 * y2,
y1, y2);
}
inline int jbig2_image_get_pixel(Jbig2Image *image, int x, int y)
{
const int w = image->width;
const int h = image->height;
const int byte = (x >> 3) + y*image->stride;
const int bit = 7 - (x & 7);
if ((x < 0) || (x >= w)) return 0;
if ((y < 0) || (y >= h)) return 0;
return ((image->data[byte] >> bit) & 1);
}
inline void ReverseBit(unsigned char* pValue)
{
unsigned char b = *pValue; // 要反转的字节
b = (unsigned char)((b * 0x0202020202ULL & 0x010884422010ULL) % 1023);
*pValue = b;
}
void print_errors()
{
int flags, line;
char *data, *file;
unsigned long code;
std::string outstr;
code = ERR_get_error_line_data((const char **)&file, &line, (const char **)&data, &flags);
while (code)
{
if (data && (flags & ERR_TXT_STRING))
{
outstr = "error data: ";
outstr += data;
outstr += "\n";
}
code = ERR_get_error_line_data((const char **)&file, &line, (const char **)&data, &flags);
}
MessageBox(nullptr, outstr.c_str(), "OPENSSL_ERROR", 0);
}
/* SESeal */
ASN1_SEQUENCE(SESeal) = {
ASN1_SIMPLE(SESeal, esealInfo, SES_SealInfo),
ASN1_SIMPLE(SESeal, signInfo, SES_SignInfo)
} ASN1_SEQUENCE_END(SESeal)
IMPLEMENT_ASN1_FUNCTIONS(SESeal)
/* V4SESeal */
ASN1_SEQUENCE(V4SESeal) = {
ASN1_SIMPLE(V4SESeal, esealInfo, V4_SES_SealInfo),
ASN1_SIMPLE(V4SESeal, cert, ASN1_OCTET_STRING),
ASN1_SIMPLE(V4SESeal, signAlgID, ASN1_OBJECT),
ASN1_SIMPLE(V4SESeal, signedValue, ASN1_BIT_STRING)
} ASN1_SEQUENCE_END(V4SESeal)
IMPLEMENT_ASN1_FUNCTIONS(V4SESeal)
/* SES_SealInfo */
ASN1_SEQUENCE(SES_SealInfo) = {
ASN1_SIMPLE(SES_SealInfo, header, SES_Header),
ASN1_SIMPLE(SES_SealInfo, esID, ASN1_IA5STRING),
ASN1_SIMPLE(SES_SealInfo, property, SES_ESPropertyInfo),
ASN1_SIMPLE(SES_SealInfo, picture, SES_ESPictrueInfo),
ASN1_EXP_SEQUENCE_OF_OPT(SES_SealInfo, extDatas, ExtData, 0)
} ASN1_SEQUENCE_END(SES_SealInfo)
IMPLEMENT_ASN1_FUNCTIONS(SES_SealInfo)
/*V4_SES_SealInfo */
ASN1_SEQUENCE(V4_SES_SealInfo) = {
ASN1_SIMPLE(V4_SES_SealInfo, header, SES_Header),
ASN1_SIMPLE(V4_SES_SealInfo, esID, ASN1_IA5STRING),
ASN1_SIMPLE(V4_SES_SealInfo, property, V4_SES_ESPropertyInfo),
ASN1_SIMPLE(V4_SES_SealInfo, picture, V4_SES_ESPictrueInfo),
ASN1_SEQUENCE_OF_OPT(V4_SES_SealInfo, extDatas, V4ExtData)
} ASN1_SEQUENCE_END(V4_SES_SealInfo)
IMPLEMENT_ASN1_FUNCTIONS(V4_SES_SealInfo)
/* ExtData */
ASN1_SEQUENCE(ExtData) = {
ASN1_SIMPLE(ExtData, extnID, ASN1_OBJECT),
ASN1_SIMPLE(ExtData, critical, ASN1_BOOLEAN),
ASN1_SIMPLE(ExtData, extnValue, ASN1_OCTET_STRING)
} ASN1_SEQUENCE_END(ExtData)
IMPLEMENT_ASN1_FUNCTIONS(ExtData)
/* V4ExtData */
ASN1_SEQUENCE(V4ExtData) = {
ASN1_SIMPLE(V4ExtData, extnID, ASN1_OBJECT),
ASN1_SIMPLE(V4ExtData, critical, ASN1_BOOLEAN),
ASN1_SIMPLE(V4ExtData, extnValue, ASN1_OCTET_STRING)
} ASN1_SEQUENCE_END(V4ExtData)
IMPLEMENT_ASN1_FUNCTIONS(V4ExtData)
/* CertDigestObj */
ASN1_SEQUENCE(CertDigestObj) = {
ASN1_SIMPLE(CertDigestObj, type, ASN1_PRINTABLESTRING),
ASN1_SIMPLE(CertDigestObj, value, ASN1_OCTET_STRING),
} ASN1_SEQUENCE_END(CertDigestObj)
IMPLEMENT_ASN1_FUNCTIONS(CertDigestObj)
/* SES_CertList */
ASN1_SEQUENCE(SES_CertList) = {
ASN1_SIMPLE(SES_CertList, certs, ASN1_OCTET_STRING),
//ASN1_IMP_SEQUENCE_OF(SES_CertList, d.certDigestList, CertDigestObj, GEN_CERTDIGESTLIST),
} ASN1_SEQUENCE_END(SES_CertList)
IMPLEMENT_ASN1_FUNCTIONS(SES_CertList)
/* SES_Header */
ASN1_SEQUENCE(SES_Header) = {
ASN1_SIMPLE(SES_Header, ID, ASN1_IA5STRING),
ASN1_SIMPLE(SES_Header, version, ASN1_INTEGER),
ASN1_SIMPLE(SES_Header, Vid, ASN1_IA5STRING)
} ASN1_SEQUENCE_END(SES_Header)
IMPLEMENT_ASN1_FUNCTIONS(SES_Header)
/* V4_SES_Header */
ASN1_SEQUENCE(V4_SES_Header) = {
ASN1_SIMPLE(V4_SES_Header, ID, ASN1_IA5STRING),
ASN1_SIMPLE(V4_SES_Header, version, ASN1_INTEGER),
ASN1_SIMPLE(V4_SES_Header, Vid, ASN1_IA5STRING)
} ASN1_SEQUENCE_END(V4_SES_Header)
IMPLEMENT_ASN1_FUNCTIONS(V4_SES_Header)
/* SES_ESPropertyInfo */
ASN1_SEQUENCE(SES_ESPropertyInfo) = {
ASN1_SIMPLE(SES_ESPropertyInfo, type, ASN1_INTEGER),
ASN1_SIMPLE(SES_ESPropertyInfo, name, ASN1_UTF8STRING),
ASN1_SEQUENCE_OF(SES_ESPropertyInfo, certList, ASN1_OCTET_STRING),
ASN1_SIMPLE(SES_ESPropertyInfo, createDate, ASN1_UTCTIME),
ASN1_SIMPLE(SES_ESPropertyInfo, validStart, ASN1_UTCTIME),
ASN1_SIMPLE(SES_ESPropertyInfo, validEnd, ASN1_UTCTIME)
} ASN1_SEQUENCE_END(SES_ESPropertyInfo)
IMPLEMENT_ASN1_FUNCTIONS(SES_ESPropertyInfo)
/* V4_SES_ESPropertyInfo */
ASN1_SEQUENCE(V4_SES_ESPropertyInfo) = {
ASN1_SIMPLE(V4_SES_ESPropertyInfo, type, ASN1_INTEGER),
ASN1_SIMPLE(V4_SES_ESPropertyInfo, name, ASN1_UTF8STRING),
ASN1_SIMPLE(V4_SES_ESPropertyInfo, certListType, ASN1_INTEGER),
ASN1_SEQUENCE_OF(V4_SES_ESPropertyInfo, certList, ASN1_OCTET_STRING),
ASN1_SIMPLE(V4_SES_ESPropertyInfo, createDate, ASN1_GENERALIZEDTIME),
ASN1_SIMPLE(V4_SES_ESPropertyInfo, validStart, ASN1_GENERALIZEDTIME),
ASN1_SIMPLE(V4_SES_ESPropertyInfo, validEnd, ASN1_GENERALIZEDTIME)
} ASN1_SEQUENCE_END(V4_SES_ESPropertyInfo)
IMPLEMENT_ASN1_FUNCTIONS(V4_SES_ESPropertyInfo)
/* SES_ESPictrueInfo */
ASN1_SEQUENCE(SES_ESPictrueInfo) = {
ASN1_SIMPLE(SES_ESPictrueInfo, type, ASN1_IA5STRING),
ASN1_SIMPLE(SES_ESPictrueInfo, data, ASN1_OCTET_STRING),
ASN1_SIMPLE(SES_ESPictrueInfo, width, ASN1_INTEGER),
ASN1_SIMPLE(SES_ESPictrueInfo, height, ASN1_INTEGER)
} ASN1_SEQUENCE_END(SES_ESPictrueInfo)
IMPLEMENT_ASN1_FUNCTIONS(SES_ESPictrueInfo)
/* V4_SES_ESPictrueInfo */
ASN1_SEQUENCE(V4_SES_ESPictrueInfo) = {
ASN1_SIMPLE(V4_SES_ESPictrueInfo, type, ASN1_IA5STRING),
ASN1_SIMPLE(V4_SES_ESPictrueInfo, data, ASN1_OCTET_STRING),
ASN1_SIMPLE(V4_SES_ESPictrueInfo, width, ASN1_INTEGER),
ASN1_SIMPLE(V4_SES_ESPictrueInfo, height, ASN1_INTEGER),
} ASN1_SEQUENCE_END(V4_SES_ESPictrueInfo)
IMPLEMENT_ASN1_FUNCTIONS(V4_SES_ESPictrueInfo)
/* SES_SignInfo */
ASN1_SEQUENCE(SES_SignInfo) = {
ASN1_SIMPLE(SES_SignInfo, cert, ASN1_OCTET_STRING),
ASN1_SIMPLE(SES_SignInfo, signatureAlorithm, ASN1_OBJECT),
ASN1_SIMPLE(SES_SignInfo, signData, ASN1_BIT_STRING)
} ASN1_SEQUENCE_END(SES_SignInfo)
IMPLEMENT_ASN1_FUNCTIONS(SES_SignInfo)
/* TBS_Sign */
ASN1_SEQUENCE(TBS_Sign) = {
ASN1_SIMPLE(TBS_Sign, version, ASN1_INTEGER),
ASN1_SIMPLE(TBS_Sign, eseal, SESeal),
ASN1_SIMPLE(TBS_Sign, timeinfo, ASN1_BIT_STRING),
ASN1_SIMPLE(TBS_Sign, dataHash, ASN1_BIT_STRING),
ASN1_SIMPLE(TBS_Sign, propertyInfo, ASN1_IA5STRING),
ASN1_SIMPLE(TBS_Sign, cert, ASN1_OCTET_STRING),
ASN1_SIMPLE(TBS_Sign, signatureAlgorithm, ASN1_OBJECT)
} ASN1_SEQUENCE_END(TBS_Sign)
IMPLEMENT_ASN1_FUNCTIONS(TBS_Sign)
/* V4_TBS_Sign */
ASN1_SEQUENCE(V4_TBS_Sign) = {
ASN1_SIMPLE(V4_TBS_Sign, version, ASN1_INTEGER),
ASN1_SIMPLE(V4_TBS_Sign, eseal, V4SESeal),
ASN1_SIMPLE(V4_TBS_Sign, timeinfo, ASN1_GENERALIZEDTIME),
ASN1_SIMPLE(V4_TBS_Sign, dataHash, ASN1_BIT_STRING),
ASN1_SIMPLE(V4_TBS_Sign, propertyInfo, ASN1_IA5STRING),
ASN1_SEQUENCE_OF_OPT(V4_TBS_Sign, extDatas, V4ExtData)
} ASN1_SEQUENCE_END(V4_TBS_Sign)
IMPLEMENT_ASN1_FUNCTIONS(V4_TBS_Sign)
/* SES_Signature */
ASN1_SEQUENCE(SES_Signature) = {
ASN1_SIMPLE(SES_Signature, toSign, TBS_Sign),
ASN1_SIMPLE(SES_Signature, signature, ASN1_BIT_STRING)
} ASN1_SEQUENCE_END(SES_Signature)
IMPLEMENT_ASN1_FUNCTIONS(SES_Signature)
/* V4_SES_Signature */
ASN1_SEQUENCE(V4_SES_Signature) = {
ASN1_SIMPLE(V4_SES_Signature, toSign, V4_TBS_Sign),
ASN1_SIMPLE(V4_SES_Signature, cert, ASN1_OCTET_STRING),
ASN1_SIMPLE(V4_SES_Signature, signatureAlgID, ASN1_OBJECT),
ASN1_SIMPLE(V4_SES_Signature, signature, ASN1_BIT_STRING),
ASN1_EXP_OPT(V4_SES_Signature, timeStamp, ASN1_BIT_STRING, 0)
} ASN1_SEQUENCE_END(V4_SES_Signature)
IMPLEMENT_ASN1_FUNCTIONS(V4_SES_Signature)