rucades 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/rucades/cplib/Blob.h +205 -163
- data/ext/rucades/cplib/CPPEnrollEnumerations.h +603 -0
- data/ext/rucades/cplib/DateTime.h +506 -455
- data/ext/rucades/cplib/StringProxy.h +229 -187
- data/ext/rucades/cplib/cpstldll.h +225 -0
- data/ext/rucades/extconf.rb +28 -12
- data/ext/rucades/rucades_about.cpp +3 -3
- data/ext/rucades/rucades_about.h +1 -1
- data/ext/rucades/rucades_algorithm.cpp +2 -2
- data/ext/rucades/rucades_algorithm.h +2 -2
- data/ext/rucades/rucades_attribute.cpp +3 -3
- data/ext/rucades/rucades_attribute.h +2 -2
- data/ext/rucades/rucades_attributes.cpp +2 -2
- data/ext/rucades/rucades_attributes.h +2 -2
- data/ext/rucades/rucades_basic_constraints.cpp +3 -3
- data/ext/rucades/rucades_basic_constraints.h +2 -2
- data/ext/rucades/rucades_blobs.cpp +3 -3
- data/ext/rucades/rucades_blobs.h +2 -2
- data/ext/rucades/rucades_certificate.cpp +3 -3
- data/ext/rucades/rucades_certificate.h +2 -2
- data/ext/rucades/rucades_certificate_status.cpp +2 -2
- data/ext/rucades/rucades_certificate_status.h +2 -2
- data/ext/rucades/rucades_certificates.cpp +8 -8
- data/ext/rucades/rucades_certificates.h +2 -2
- data/ext/rucades/rucades_crl.cpp +1 -1
- data/ext/rucades/rucades_crl.h +1 -1
- data/ext/rucades/rucades_eku.cpp +2 -2
- data/ext/rucades/rucades_eku.h +2 -2
- data/ext/rucades/rucades_ekus.cpp +3 -3
- data/ext/rucades/rucades_ekus.h +2 -2
- data/ext/rucades/rucades_encoded_data.cpp +1 -1
- data/ext/rucades/rucades_encoded_data.h +1 -1
- data/ext/rucades/rucades_enveloped_data.cpp +1 -1
- data/ext/rucades/rucades_enveloped_data.h +1 -1
- data/ext/rucades/rucades_extended_key_usage.cpp +2 -2
- data/ext/rucades/rucades_extended_key_usage.h +2 -2
- data/ext/rucades/rucades_hashed_data.cpp +1 -1
- data/ext/rucades/rucades_hashed_data.h +1 -1
- data/ext/rucades/rucades_key_usage.cpp +3 -3
- data/ext/rucades/rucades_key_usage.h +2 -2
- data/ext/rucades/rucades_oid.cpp +3 -3
- data/ext/rucades/rucades_oid.h +2 -2
- data/ext/rucades/rucades_private_key.cpp +3 -3
- data/ext/rucades/rucades_private_key.h +2 -2
- data/ext/rucades/rucades_public_key.cpp +2 -2
- data/ext/rucades/rucades_public_key.h +2 -2
- data/ext/rucades/rucades_raw_signature.cpp +2 -2
- data/ext/rucades/rucades_raw_signature.h +2 -2
- data/ext/rucades/rucades_recipients.cpp +2 -2
- data/ext/rucades/rucades_recipients.h +2 -2
- data/ext/rucades/rucades_signature_status.cpp +2 -2
- data/ext/rucades/rucades_signature_status.h +2 -2
- data/ext/rucades/rucades_signed_data.cpp +7 -7
- data/ext/rucades/rucades_signed_data.h +1 -1
- data/ext/rucades/rucades_signed_xml.cpp +2 -2
- data/ext/rucades/rucades_signed_xml.h +1 -1
- data/ext/rucades/rucades_signer.cpp +8 -8
- data/ext/rucades/rucades_signer.h +2 -2
- data/ext/rucades/rucades_signers.cpp +2 -2
- data/ext/rucades/rucades_signers.h +2 -2
- data/ext/rucades/rucades_store.cpp +2 -2
- data/ext/rucades/rucades_store.h +1 -1
- data/ext/rucades/rucades_symmetric_algorithm.cpp +3 -3
- data/ext/rucades/rucades_symmetric_algorithm.h +2 -2
- data/ext/rucades/rucades_version.cpp +2 -2
- data/ext/rucades/rucades_version.h +2 -2
- data/ext/rucades/stdafx.h +207 -121
- data/lib/rucades/version.rb +1 -1
- data/samples/encrypt_decrypt.rb +17 -14
- data/samples/sign_verify.rb +14 -17
- data/sig/rucades.rbs +850 -1
- metadata +3 -4
- data/ext/rucades/cpstldll.h +0 -183
- data/ext/rucades/errormsg.cpp +0 -561
- data/ext/rucades/errormsg.h +0 -31
|
@@ -13,9 +13,9 @@ using namespace CryptoPro::PKI::CAdES;
|
|
|
13
13
|
|
|
14
14
|
namespace rucades {
|
|
15
15
|
pre_rb_Version::pre_rb_Version(void):
|
|
16
|
-
m_pCppCadesImpl(
|
|
16
|
+
m_pCppCadesImpl(NS_SHARED_PTR::shared_ptr<CPPVersionObject>(new CPPVersionObject())) { }
|
|
17
17
|
|
|
18
|
-
pre_rb_Version::pre_rb_Version(
|
|
18
|
+
pre_rb_Version::pre_rb_Version(NS_SHARED_PTR::shared_ptr<CPPVersionObject> other):
|
|
19
19
|
m_pCppCadesImpl(other) { }
|
|
20
20
|
|
|
21
21
|
unsigned int pre_rb_Version::major_version(void)
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
namespace rucades {
|
|
11
11
|
class pre_rb_Version {
|
|
12
12
|
protected:
|
|
13
|
-
|
|
13
|
+
NS_SHARED_PTR::shared_ptr<CryptoPro::PKI::CAdES::CPPVersionObject> m_pCppCadesImpl;
|
|
14
14
|
public:
|
|
15
15
|
pre_rb_Version(void);
|
|
16
|
-
pre_rb_Version(
|
|
16
|
+
pre_rb_Version(NS_SHARED_PTR::shared_ptr<CryptoPro::PKI::CAdES::CPPVersionObject> other);
|
|
17
17
|
unsigned int major_version(void);
|
|
18
18
|
unsigned int minor_version(void);
|
|
19
19
|
unsigned int build_version(void);
|
data/ext/rucades/stdafx.h
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// stdafx.h : include file for standard system include files,
|
|
2
|
-
// or project specific include files that are used frequently, but
|
|
3
|
-
// are changed infrequently
|
|
4
|
-
//
|
|
5
1
|
#pragma once
|
|
6
2
|
|
|
7
3
|
#define CRYPT_SIGN_MESSAGE_PARA_HAS_CMS_FIELDS
|
|
@@ -9,115 +5,32 @@
|
|
|
9
5
|
#define CMSG_SIGNED_ENCODE_INFO_HAS_CMS_FIELDS
|
|
10
6
|
#define CERT_PARA_HAS_EXTRA_FIELDS
|
|
11
7
|
|
|
12
|
-
#define
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#define RETURN_ATL_STRINGL RETURN_ATL_STRINGL_W
|
|
17
|
-
#endif
|
|
8
|
+
#define IS_CADES_VERSION_GREATER_EQUAL(major, minor, build) \
|
|
9
|
+
(CPRO_CADES_VERSION_MAJOR > (major) || \
|
|
10
|
+
(CPRO_CADES_VERSION_MAJOR == (major) && CPRO_CADES_VERSION_MINOR > (minor)) || \
|
|
11
|
+
(CPRO_CADES_VERSION_MAJOR == (major) && CPRO_CADES_VERSION_MINOR == (minor) && CPRO_CADES_VERSION_BUILD >= (build)))
|
|
18
12
|
|
|
13
|
+
#define IGNORE_LEGACY_FORMAT_MESSAGE_MSG
|
|
19
14
|
|
|
20
|
-
#include "boost/shared_ptr.hpp"
|
|
21
15
|
#include <iostream>
|
|
22
|
-
#include <memory> //Этот хедер тут нужен что бы компилить с новыми версиями libstdc++
|
|
23
|
-
//в них есть конфликт с __in и __out макросами которые определены в MS хедерах.
|
|
24
|
-
|
|
25
|
-
#ifdef UNIX
|
|
26
16
|
#include "CSP_WinDef.h"
|
|
27
17
|
#include "CSP_WinError.h"
|
|
28
|
-
#include <string>
|
|
29
|
-
#include <stdarg.h>
|
|
30
|
-
#include <atldef2.h>
|
|
31
|
-
#define CADES_CLASS
|
|
32
|
-
#define RETURN_ATL_STRING RETURN_ATL_STRING_A
|
|
33
|
-
#define RETURN_ATL_STRINGL RETURN_ATL_STRINGL_A
|
|
34
|
-
#endif //UNIX
|
|
35
18
|
#include <WinCryptEx.h>
|
|
36
|
-
|
|
37
|
-
#include "atltrace2.h"
|
|
38
|
-
#include <atldef2.h>
|
|
39
|
-
#include <atlenc.h>
|
|
40
19
|
#include <atlcrypt2.h>
|
|
20
|
+
#include "ocspcli_e.h"
|
|
21
|
+
#include "tspcli_e.h"
|
|
22
|
+
#include "cppcades.h"
|
|
41
23
|
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
// turns off ATL's hiding of some common and often safely ignored warning messages
|
|
46
|
-
#define _ATL_ALL_WARNINGS
|
|
47
|
-
|
|
48
|
-
#include <atlbase.h>
|
|
49
|
-
#ifdef _WIN32
|
|
50
|
-
#include <atlcom.h>
|
|
51
|
-
#endif //_WIN32
|
|
52
|
-
#pragma warning(push)
|
|
53
|
-
#pragma warning(disable : 4127)
|
|
54
|
-
#include <atlstr.h>
|
|
55
|
-
#pragma warning(pop)
|
|
56
|
-
#include "errormsg.h"
|
|
57
|
-
|
|
58
|
-
#ifndef UNIX
|
|
59
|
-
#pragma warning(push)
|
|
60
|
-
#pragma warning(disable : 4005)
|
|
24
|
+
#ifndef NS_SHARED_PTR
|
|
25
|
+
#define NS_SHARED_PTR boost
|
|
26
|
+
#include "boost/shared_ptr.hpp"
|
|
61
27
|
#endif
|
|
62
28
|
|
|
63
|
-
#
|
|
64
|
-
{ \
|
|
65
|
-
char *str; \
|
|
66
|
-
int len = 0; \
|
|
67
|
-
len = atlstr.GetLength(); \
|
|
68
|
-
str = (char *)ecalloc(len + 1, sizeof(char)); \
|
|
69
|
-
wcstombs(str, atlstr, len); \
|
|
70
|
-
str[len] = '\0'; \
|
|
71
|
-
RETURN_STRING(str, 0) \
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
#define RETURN_ATL_STRINGL_W(atlstr) \
|
|
75
|
-
{ \
|
|
76
|
-
char *str; \
|
|
77
|
-
int len = 0; \
|
|
78
|
-
len = atlstr.GetLength(); \
|
|
79
|
-
str = (char *)ecalloc(len, sizeof(char)); \
|
|
80
|
-
wcstombs(str, atlstr, len); \
|
|
81
|
-
RETURN_STRINGL(str, len, 0) \
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
#define RETURN_ATL_STRING_A(atlstr) \
|
|
85
|
-
{ \
|
|
86
|
-
char *str; \
|
|
87
|
-
int len = 0; \
|
|
88
|
-
len = atlstr.GetLength(); \
|
|
89
|
-
str = (char *)ecalloc(len + 1, sizeof(char)); \
|
|
90
|
-
memcpy(str, atlstr, len); \
|
|
91
|
-
str[len] = '\0'; \
|
|
92
|
-
RETURN_STRING(str, 0) \
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
#define RETURN_ATL_STRINGL_A(atlstr) \
|
|
96
|
-
{ \
|
|
97
|
-
char *str; \
|
|
98
|
-
int len = 0; \
|
|
99
|
-
len = atlstr.GetLength(); \
|
|
100
|
-
str = (char *)ecalloc(len, sizeof(char)); \
|
|
101
|
-
memcpy(str, atlstr, len); \
|
|
102
|
-
RETURN_STRINGL(str, len, 0) \
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
#define RETURN_PROXY_STRING(prstr) \
|
|
106
|
-
{ \
|
|
107
|
-
char *str; \
|
|
108
|
-
int len = 0; \
|
|
109
|
-
len = strlen(prstr.c_str()); \
|
|
110
|
-
str = (char *)ecalloc(len + 1, sizeof(char)); \
|
|
111
|
-
strncpy(str, prstr.c_str(), len + 1); \
|
|
112
|
-
RETURN_STRING(str, 0) \
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
#ifdef UNIX //разные макросы ибо на линуксе нет _vscwprintf() который нужен внутри AppendFormat().
|
|
29
|
+
#include "CSP_WinCrypt.h"
|
|
116
30
|
|
|
117
31
|
#ifdef MAKELANGID
|
|
118
32
|
#undef MAKELANGID
|
|
119
33
|
#endif //MAKELANGID
|
|
120
|
-
|
|
121
34
|
#define MAKELANGID(a, b) 0x409 //English U.S.
|
|
122
35
|
|
|
123
36
|
#define RETURN_NULL_WITH_EXCEPTION(err) \
|
|
@@ -144,28 +57,6 @@
|
|
|
144
57
|
return -1; \
|
|
145
58
|
} while (0)
|
|
146
59
|
|
|
147
|
-
#else
|
|
148
|
-
#define RETURN_NULL_WITH_EXCEPTION(err) \
|
|
149
|
-
do \
|
|
150
|
-
{ \
|
|
151
|
-
CAtlStringW message = GetErrorMessage(HRESULT_FROM_WIN32(err), \
|
|
152
|
-
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); \
|
|
153
|
-
message.AppendFormat(L" (0x%08X)", err); \
|
|
154
|
-
PyErr_SetString(PyExc_Exception, CW2A(message, CP_UTF8)); \
|
|
155
|
-
return NULL; \
|
|
156
|
-
} while (0)
|
|
157
|
-
|
|
158
|
-
#define RETURN_MINUS_1_WITH_EXCEPTION(err) \
|
|
159
|
-
do \
|
|
160
|
-
{ \
|
|
161
|
-
CAtlStringW message = GetErrorMessage(HRESULT_FROM_WIN32(err), \
|
|
162
|
-
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); \
|
|
163
|
-
message.AppendFormat(L" (0x%08X)", err); \
|
|
164
|
-
PyErr_SetString(PyExc_Exception, CW2A(message, CP_UTF8)); \
|
|
165
|
-
return -1; \
|
|
166
|
-
} while (0)
|
|
167
|
-
|
|
168
|
-
#endif //UNIX
|
|
169
60
|
|
|
170
61
|
#define HR_SETTER_ERRORCHECK_RETURN(expr) \
|
|
171
62
|
__pragma(warning(push)) \
|
|
@@ -188,3 +79,198 @@
|
|
|
188
79
|
RETURN_NULL_WITH_EXCEPTION(stdafx_hr); \
|
|
189
80
|
} \
|
|
190
81
|
} while (0)
|
|
82
|
+
|
|
83
|
+
static const ATL::CAtlStringW GetErrorMessage(HRESULT hr, DWORD dwLangId) {
|
|
84
|
+
UNUSED(dwLangId);
|
|
85
|
+
ATL::CAtlStringW ret;
|
|
86
|
+
switch (hr) {
|
|
87
|
+
case TSPCLI_ERROR_HTTP:
|
|
88
|
+
case OCSPCLI_ERROR_HTTP:
|
|
89
|
+
ret = L"HTTP error occurred while sending request.";
|
|
90
|
+
break;
|
|
91
|
+
case TSPCLI_ERROR_PolicyDeniedAuthType:
|
|
92
|
+
case OCSPCLI_ERROR_PolicyDeniedAuthType:
|
|
93
|
+
ret = L"Specified authentication type prohibited by group policy.";
|
|
94
|
+
break;
|
|
95
|
+
case TSPCLI_ERROR_PolicyDeniedProxyAuthType:
|
|
96
|
+
case OCSPCLI_ERROR_PolicyDeniedProxyAuthType:
|
|
97
|
+
ret = L"Specified proxy authentication type prohibited by group policy.";
|
|
98
|
+
break;
|
|
99
|
+
case TSPCLI_ERROR_PolicyDeniedURL:
|
|
100
|
+
ret = L"Specified time-stamp authority prohibited by group policy.";
|
|
101
|
+
break;
|
|
102
|
+
case OCSPCLI_ERROR_PolicyDeniedURL:
|
|
103
|
+
ret = L"Specified OCSP server authority prohibited by group policy.";
|
|
104
|
+
break;
|
|
105
|
+
case TSPCLI_ERROR_PolicyDeniedNonce:
|
|
106
|
+
ret = L"Nonce usage prohibited by group policy.";
|
|
107
|
+
break;
|
|
108
|
+
case TSPCLI_ERROR_PolicyDeniedHashAlg:
|
|
109
|
+
ret = L"Specified hash algorithm prohibited by group policy.";
|
|
110
|
+
break;
|
|
111
|
+
case TSPCLI_ERROR_PolicyDeniedPolicyID:
|
|
112
|
+
ret = L"Specified PolicyID prohibited by group policy.";
|
|
113
|
+
break;
|
|
114
|
+
case TSPCLI_ERROR_IncorrectNonce:
|
|
115
|
+
ret = L" The values of request's and stamp's \"Nonce\" fields are not equal.";
|
|
116
|
+
break;
|
|
117
|
+
case TSPCLI_ERROR_AddressIsEmpty:
|
|
118
|
+
ret = L"The URL of TSP service is not specified.";
|
|
119
|
+
break;
|
|
120
|
+
case TSPCLI_ERROR_ExpiredStamp:
|
|
121
|
+
ret = L"The time stamp is expired (ProducedAt value).";
|
|
122
|
+
break;
|
|
123
|
+
case TSPCLI_ERROR_DataHashIsEmpty:
|
|
124
|
+
ret = L"Request does not contain data hash.";
|
|
125
|
+
break;
|
|
126
|
+
case TSPCLI_ERROR_UnsuccessfullResponse:
|
|
127
|
+
ret = L"TSA response is unsuccessful.";
|
|
128
|
+
break;
|
|
129
|
+
case 0xC2100140: // TSPCLI_ERROR_LicenseExpired
|
|
130
|
+
ret = L"No TSP Client license has been entered or TSP Client license is expired.";
|
|
131
|
+
break;
|
|
132
|
+
case OCSPCLI_ERROR_PolicyDeniedSignedRequest:
|
|
133
|
+
ret = L"Signed OCSP requests prohibited by group policy.";
|
|
134
|
+
break;
|
|
135
|
+
case OCSPCLI_ERROR_PolicyDeniedUnsignedRequest:
|
|
136
|
+
ret = L"Unsigned OCSP requests prohibited by group policy.";
|
|
137
|
+
break;
|
|
138
|
+
case OCSPCLI_ERROR_IncorrectNonce:
|
|
139
|
+
ret = L"The values of OCSP-request's and response's \"Nonce\" extensions are not equal.";
|
|
140
|
+
break;
|
|
141
|
+
case OCSPCLI_ERROR_AddressIsEmpty:
|
|
142
|
+
ret = L"The URL of OCSP service is not specified.";
|
|
143
|
+
break;
|
|
144
|
+
case OCSPCLI_ERROR_ExpiredResponse:
|
|
145
|
+
ret = L"OCSP-response is expired by ProducedAt or by NextUpdate.";
|
|
146
|
+
break;
|
|
147
|
+
case OCSPCLI_ERROR_ExpiredThisUpdate:
|
|
148
|
+
ret = L"ThisUpdate value of single response is expired.";
|
|
149
|
+
break;
|
|
150
|
+
case OCSPCLI_ERROR_IncorrectNextUpdate:
|
|
151
|
+
ret = L" NextUpdate value of single response is less than ThisUpdate.";
|
|
152
|
+
break;
|
|
153
|
+
case OCSPCLI_ERROR_ReqRespNotMatch:
|
|
154
|
+
ret = L"OCSP-response does not contain requested certificate status.";
|
|
155
|
+
break;
|
|
156
|
+
case OCSPCLI_ERROR_CertStatusIsRevoked:
|
|
157
|
+
ret = L"Certificate is revoked.";
|
|
158
|
+
break;
|
|
159
|
+
case OCSPCLI_ERROR_CertStatusIsUnknown:
|
|
160
|
+
ret = L"Certificate status is unknown.";
|
|
161
|
+
break;
|
|
162
|
+
case OCSPCLI_ERROR_UnsuccessfullResponse:
|
|
163
|
+
ret = L"OCSP-response is unsuccessful.";
|
|
164
|
+
break;
|
|
165
|
+
case OCSPCLI_ERROR_PolicyDeniedExtension:
|
|
166
|
+
ret = L"Encountered extension (AcceptableTypes or Nonce) prohibited by group policy.";
|
|
167
|
+
break;
|
|
168
|
+
case ERROR_BAD_CONFIGURATION:
|
|
169
|
+
ret = L"The configuration data or license for this product is corrupt or not present.";
|
|
170
|
+
break;
|
|
171
|
+
case 0x8007064a: // License info isn't present
|
|
172
|
+
ret = L"The configuration data or license for this product is corrupt or not present.";
|
|
173
|
+
break;
|
|
174
|
+
case CRYPT_E_REVOKED:
|
|
175
|
+
ret = L"The certificate is revoked.";
|
|
176
|
+
break;
|
|
177
|
+
case ERROR_NO_DATA_DETECTED:
|
|
178
|
+
ret = L"The data you supplied have zero length.";
|
|
179
|
+
break;
|
|
180
|
+
case CRYPT_E_NO_REVOCATION_CHECK:
|
|
181
|
+
ret = L"The revocation function was unable to check revocation for the certificate.";
|
|
182
|
+
break;
|
|
183
|
+
case 0x8007006E:
|
|
184
|
+
ret = L"The system cannot open the device or file specified.";
|
|
185
|
+
break;
|
|
186
|
+
case NTE_BAD_ALGID:
|
|
187
|
+
case CRYPT_E_OID_FORMAT: // oid UNIX
|
|
188
|
+
ret = L"Invalid algorithm specified.";
|
|
189
|
+
break;
|
|
190
|
+
case REGDB_E_CLASSNOTREG:
|
|
191
|
+
ret = L"Class not registered.";
|
|
192
|
+
break;
|
|
193
|
+
case OLE_E_BLANK:
|
|
194
|
+
ret = L"Uninitialized object.";
|
|
195
|
+
break;
|
|
196
|
+
case CAPICOM_E_STORE_NOT_OPENED:
|
|
197
|
+
ret = L"The Store object does not represent an opened certificate store.";
|
|
198
|
+
break;
|
|
199
|
+
case E_INVALIDARG:
|
|
200
|
+
ret = L"The parameter is incorrect.";
|
|
201
|
+
break;
|
|
202
|
+
case 0x80070002: // returned by OpenStore(Existing) if no store
|
|
203
|
+
ret = L"The system cannot find the file specified.";
|
|
204
|
+
break;
|
|
205
|
+
case E_NOT_VALID_STATE:
|
|
206
|
+
ret = L"The group or resource is not in the correct state to perform the requested operation.";
|
|
207
|
+
break;
|
|
208
|
+
case E_NOTIMPL:
|
|
209
|
+
ret = L"Not implemented.";
|
|
210
|
+
break;
|
|
211
|
+
case ERROR_ALREADY_EXISTS:
|
|
212
|
+
ret = L"Cannot create a file when that file already exists.";
|
|
213
|
+
break;
|
|
214
|
+
case 0x800700B7: // ERROR_ALREADY_EXISTS in HRESULT variant
|
|
215
|
+
ret = L"Cannot create a file when that file already exists.";
|
|
216
|
+
break;
|
|
217
|
+
case NS_E_CURL_INVALIDSCHEME:
|
|
218
|
+
ret = L"The URL contains an invalid scheme.";
|
|
219
|
+
break;
|
|
220
|
+
case SCARD_W_WRONG_CHV:
|
|
221
|
+
ret = L"The private key cannot be accessed because the wrong PIN was presented.";
|
|
222
|
+
break;
|
|
223
|
+
case CRYPT_E_NOT_FOUND:
|
|
224
|
+
ret = L"Cannot find object or property.";
|
|
225
|
+
break;
|
|
226
|
+
case NTE_BAD_SIGNATURE:
|
|
227
|
+
ret = L"Invalid Signature.";
|
|
228
|
+
break;
|
|
229
|
+
case ERROR_DS_INSUFF_ACCESS_RIGHTS:
|
|
230
|
+
ret = L"Insufficient access rights to perform the operation.";
|
|
231
|
+
break;
|
|
232
|
+
case 0x800705B9: // ERROR_XML_PARSE_ERROR in HRESULT variant
|
|
233
|
+
ret = L"The system was unable to parse the requested XML data.";
|
|
234
|
+
break;
|
|
235
|
+
case 0x800705BA: // ERROR_XMLDSIG_ERROR in HRESULT variant
|
|
236
|
+
ret = L"An error was encountered while processing an XML digital signature.";
|
|
237
|
+
break;
|
|
238
|
+
case 0x800B010E: // CERT_E_REVOCATION_FAILURE
|
|
239
|
+
ret = L"The revocation process could not continue - the certificate(s) could not be checked.";
|
|
240
|
+
break;
|
|
241
|
+
case OCSPCLI_ERROR_ResponseWithUnallowedExtension:
|
|
242
|
+
ret = L"OCSP-response contains unallowed critical extension.";
|
|
243
|
+
break;
|
|
244
|
+
case NTE_EXISTS:
|
|
245
|
+
ret = L"Object already exists.";
|
|
246
|
+
break;
|
|
247
|
+
case CRYPT_E_HASH_VALUE:
|
|
248
|
+
ret = L"The hash value is not correct";
|
|
249
|
+
break;
|
|
250
|
+
case OCSPCLI_ERROR_ResponseWithIncorrectTimeStamp:
|
|
251
|
+
ret = L"OCSP Responder time is out of sync with Time Stamping Authority";
|
|
252
|
+
break;
|
|
253
|
+
case OCSPCLI_ERROR_UntrustedSitesDisabled:
|
|
254
|
+
ret = L"Untrusted sites disabled";
|
|
255
|
+
break;
|
|
256
|
+
case 0xC2110140: // OCSPCLI_ERROR_LicenseExpired
|
|
257
|
+
ret = L"No OCSP Client license has been entered or OCSP Client license is expired";
|
|
258
|
+
break;
|
|
259
|
+
case SCARD_E_CARD_UNSUPPORTED:
|
|
260
|
+
ret = L"Wrong name format or an attempt is made to open container of another CSP.";
|
|
261
|
+
break;
|
|
262
|
+
case NTE_PERM:
|
|
263
|
+
ret = L"Access denied";
|
|
264
|
+
break;
|
|
265
|
+
case CERT_E_UNTRUSTEDROOT:
|
|
266
|
+
ret = L"A certificate chain processed correctly, but terminated in a root certificate which is not trusted by the trust provider";
|
|
267
|
+
break;
|
|
268
|
+
case CRYPT_E_NO_DECRYPT_CERT:
|
|
269
|
+
ret = L"Cannot find the certificate and private key to use for decryption";
|
|
270
|
+
break;
|
|
271
|
+
default:
|
|
272
|
+
ret = L"Internal error.";
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
return ret;
|
|
276
|
+
}
|
data/lib/rucades/version.rb
CHANGED
data/samples/encrypt_decrypt.rb
CHANGED
|
@@ -9,17 +9,20 @@ certs = store.certificates
|
|
|
9
9
|
|
|
10
10
|
raise "Certificates with private key not found" unless certs.any?
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
puts
|
|
20
|
-
puts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
# hashed_data = Rucades::HashedData.new
|
|
13
|
+
|
|
14
|
+
enveloped_data = Rucades::EnvelopedData.new
|
|
15
|
+
enveloped_data.content = "Message to encrypt с русскими буквами"
|
|
16
|
+
enveloped_data.recipients.add(certs[1])
|
|
17
|
+
encrypted_message = enveloped_data.encrypt(Rucades::CADESCOM_ENCODE_BASE64)
|
|
18
|
+
puts "============= Encrypted Message ============="
|
|
19
|
+
puts encrypted_message
|
|
20
|
+
puts "============================================="
|
|
21
|
+
|
|
22
|
+
enveloped_data_dec = Rucades::EnvelopedData.new
|
|
23
|
+
enveloped_data_dec.decrypt(encrypted_message)
|
|
24
|
+
content = enveloped_data_dec.content
|
|
25
|
+
|
|
26
|
+
raise "Incorrect value of EnvelopedData.decrypt result" unless content == "Message to encrypt с русскими буквами"
|
|
27
|
+
|
|
28
|
+
puts "=========== Decrypted successfully =========="
|
data/samples/sign_verify.rb
CHANGED
|
@@ -9,20 +9,17 @@ certs = store.certificates
|
|
|
9
9
|
|
|
10
10
|
raise "Certificates with private key not found" unless certs.any?
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
puts
|
|
20
|
-
puts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
raise "Incorrect value of EnvelopedData.decrypt result" unless content == "Message to encrypt с русскими буквами"
|
|
27
|
-
|
|
28
|
-
puts "=========== Decrypted successfully =========="
|
|
12
|
+
signer = Rucades::Signer.new
|
|
13
|
+
signer.certificate = certs[1]
|
|
14
|
+
signer.check_certificate = true
|
|
15
|
+
|
|
16
|
+
signed_data = Rucades::SignedData.new
|
|
17
|
+
signed_data.content = "Test content to be signed"
|
|
18
|
+
signature = signed_data.sign_cades(signer, Rucades::CADESCOM_CADES_BES)
|
|
19
|
+
puts "============= Signature ============="
|
|
20
|
+
puts signature
|
|
21
|
+
puts "====================================="
|
|
22
|
+
|
|
23
|
+
signed_data2 = Rucades::SignedData.new
|
|
24
|
+
signed_data2.verify_cades(signature, Rucades::CADESCOM_CADES_BES)
|
|
25
|
+
puts "******* Verified successfully ******"
|