ReactOS 0.4.17-dev-1037-g720d112
ncrypt.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <ncrypt.h>
#include <bcrypt.h>
#include "wine/test.h"
Include dependency graph for ncrypt.c:

Go to the source code of this file.

Classes

struct  expected_property
 

Macros

#define check_properties(a, b)   _check_properties(__LINE__, a, b)
 

Functions

static void check_property (int line, NCRYPT_KEY_HANDLE key, const struct expected_property *property)
 
static void _check_properties (int line, NCRYPT_PROV_HANDLE prov, NCRYPT_KEY_HANDLE key)
 
static void test_key_import_rsa (void)
 
static void test_free_object (void)
 
static void test_get_property (void)
 
static void test_set_property (void)
 
static void test_create_persisted_key (void)
 
static void test_finalize_key (void)
 
static void test_verify_signature (void)
 
static void test_NCryptIsAlgSupported (void)
 
static void test_NCryptEncrypt (void)
 
static void test_NCryptExportKey (void)
 
 START_TEST (ncrypt)
 

Variables

static UCHAR rsa_key_blob []
 
static UCHAR rsa_private_key_blob []
 
static UCHAR rsa_full_private_key_blob []
 
static UCHAR rsa_key_blob_with_invalid_bit_length []
 
static UCHAR rsa_key_blob_with_invalid_publicexp_size []
 
static UCHAR invalid_rsa_key_blob []
 
static UCHAR signature_pubkey_blob []
 
static UCHAR signature_pkcs1_sha256 []
 
static UCHAR invalid_signature []
 
static UCHAR sha256_hash []
 
static UCHAR data_to_encrypt [12] = "Hello world"
 

Macro Definition Documentation

◆ check_properties

#define check_properties (   a,
  b 
)    _check_properties(__LINE__, a, b)

Definition at line 232 of file ncrypt.c.

Function Documentation

◆ _check_properties()

static void _check_properties ( int  line,
NCRYPT_PROV_HANDLE  prov,
NCRYPT_KEY_HANDLE  key 
)
static

Definition at line 233 of file ncrypt.c.

234{
236 {
237 /* NCrypt properties */
240 {NCRYPT_ALGORITHM_PROPERTY, {'R', 0, 'S', 0, 'A', 0}, sizeof(L"RSA"), ERROR_SUCCESS},
241 {NCRYPT_LENGTH_PROPERTY, {0, 0x4} /* 1024 */, sizeof(DWORD)},
242 {NCRYPT_LENGTHS_PROPERTY, {0, 0x2, 0, 0, 0, 0x40, 0, 0, 0x8, 0, 0, 0, 0, 0x4, 0, 0}, sizeof(DWORD) * 4 /* NCRYPT_SUPPORTED_LENGTHS */, ERROR_SUCCESS, FALSE, ERROR_SUCCESS, {0, 0x2, 0, 0, 0, 0x40, 0, 0, 0x40, 0, 0, 0, 0, 0x4, 0, 0}},
243 {NCRYPT_BLOCK_LENGTH_PROPERTY, {0x80, 0, 0, 0}, sizeof(DWORD), ERROR_SUCCESS},
249 {NCRYPT_KEY_USAGE_PROPERTY, {0xff, 0xff, 0xff, 0} /* NCRYPT_ALLOW_ALL_USAGES */, sizeof(DWORD), ERROR_SUCCESS},
259 {NCRYPT_ALGORITHM_GROUP_PROPERTY, {'R', 0, 'S', 0, 'A', 0}, sizeof(L"RSA")},
272 /* BCrypt properties */
289 {BCRYPT_SIGNATURE_LENGTH, {0x80, 0, 0, 0} /* 128 */, sizeof(DWORD), ERROR_SUCCESS, FALSE, NTE_NOT_SUPPORTED /* <= Win 8 */},
290 {BCRYPT_PUBLIC_KEY_LENGTH, {0, 0x4} /* 1024 */, sizeof(DWORD), ERROR_SUCCESS, FALSE, NTE_NOT_SUPPORTED /* <= Win 8 */},
291 };
292 unsigned int i;
293
294 for (i = 0; i < ARRAY_SIZE(properties); i++)
295 {
297 memcpy(properties[i].expected_data, &prov, sizeof(prov));
298
300 }
301}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define BCRYPT_KEY_LENGTHS
Definition: bcrypt.h:62
#define BCRYPT_PUBLIC_KEY_LENGTH
Definition: bcrypt.h:69
#define BCRYPT_SIGNATURE_LENGTH
Definition: bcrypt.h:68
#define BCRYPT_PROVIDER_HANDLE
Definition: bcrypt.h:67
#define BCRYPT_HASH_BLOCK_LENGTH
Definition: bcrypt.h:57
#define BCRYPT_OBJECT_LENGTH
Definition: bcrypt.h:65
#define BCRYPT_KEY_LENGTH
Definition: bcrypt.h:61
#define BCRYPT_AUTH_TAG_LENGTH
Definition: bcrypt.h:52
#define BCRYPT_CHAINING_MODE
Definition: bcrypt.h:55
#define BCRYPT_HASH_OID_LIST
Definition: bcrypt.h:59
#define BCRYPT_ALGORITHM_NAME
Definition: bcrypt.h:51
#define BCRYPT_KEY_STRENGTH
Definition: bcrypt.h:64
#define BCRYPT_BLOCK_LENGTH
Definition: bcrypt.h:53
#define BCRYPT_EFFECTIVE_KEY_LENGTH
Definition: bcrypt.h:56
#define BCRYPT_HASH_LENGTH
Definition: bcrypt.h:58
#define BCRYPT_BLOCK_SIZE_LIST
Definition: bcrypt.h:54
#define BCRYPT_PADDING_SCHEMES
Definition: bcrypt.h:66
#define BCRYPT_KEY_OBJECT_LENGTH
Definition: bcrypt.h:63
static const D2D1_CREATION_PROPERTIES * properties
Definition: d2d1.c:299
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
#define L(x)
Definition: resources.c:13
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _FILETIME FILETIME
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define check_property(a, b, c, d)
Definition: query.c:249
#define NCRYPT_CERTIFICATE_PROPERTY
Definition: ncrypt.h:130
#define NCRYPT_READER_PROPERTY
Definition: ncrypt.h:128
#define NCRYPT_USE_CONTEXT_PROPERTY
Definition: ncrypt.h:114
#define NCRYPT_BLOCK_LENGTH_PROPERTY
Definition: ncrypt.h:110
#define NCRYPT_PROVIDER_HANDLE_PROPERTY
Definition: ncrypt.h:126
#define NCRYPT_SECURITY_DESCR_SUPPORT_PROPERTY
Definition: ncrypt.h:119
#define NCRYPT_ALGORITHM_PROPERTY
Definition: ncrypt.h:107
#define NCRYPT_MAX_NAME_LENGTH_PROPERTY
Definition: ncrypt.h:124
#define NCRYPT_NAME_PROPERTY
Definition: ncrypt.h:105
#define NCRYPT_SCARD_PIN_ID
Definition: ncrypt.h:136
#define NCRYPT_VERSION_PROPERTY
Definition: ncrypt.h:118
#define NCRYPT_USE_COUNT_PROPERTY
Definition: ncrypt.h:122
#define NCRYPT_PIN_PROMPT_PROPERTY
Definition: ncrypt.h:131
#define NCRYPT_ALGORITHM_GROUP_PROPERTY
Definition: ncrypt.h:125
#define NCRYPT_USER_CERTSTORE_PROPERTY
Definition: ncrypt.h:132
#define NCRYPT_LENGTHS_PROPERTY
Definition: ncrypt.h:109
#define NCRYPT_IMPL_TYPE_PROPERTY
Definition: ncrypt.h:115
#define NCRYPT_SCARD_PIN_INFO
Definition: ncrypt.h:137
#define NCRYPT_LENGTH_PROPERTY
Definition: ncrypt.h:108
#define NCRYPT_SMARTCARD_GUID_PROPERTY
Definition: ncrypt.h:129
#define NCRYPT_EXPORT_POLICY_PROPERTY
Definition: ncrypt.h:112
#define NCRYPT_KEY_TYPE_PROPERTY
Definition: ncrypt.h:117
#define NCRYPT_SECURE_PIN_PROPERTY
Definition: ncrypt.h:134
#define NCRYPT_UI_POLICY_PROPERTY
Definition: ncrypt.h:111
#define NCRYPT_PIN_PROPERTY
Definition: ncrypt.h:127
#define NCRYPT_ROOT_CERTSTORE_PROPERTY
Definition: ncrypt.h:133
ULONG_PTR NCRYPT_PROV_HANDLE
Definition: ncrypt.h:77
#define NCRYPT_UNIQUE_NAME_PROPERTY
Definition: ncrypt.h:106
#define NCRYPT_SECURITY_DESCR_PROPERTY
Definition: ncrypt.h:120
#define NCRYPT_ASSOCIATED_ECDH_KEY
Definition: ncrypt.h:135
#define NCRYPT_USE_COUNT_ENABLED_PROPERTY
Definition: ncrypt.h:121
struct __NCRYPT_UI_POLICY NCRYPT_UI_POLICY
#define NCRYPT_KEY_USAGE_PROPERTY
Definition: ncrypt.h:116
#define NCRYPT_WINDOW_HANDLE_PROPERTY
Definition: ncrypt.h:113
#define NCRYPT_LAST_MODIFIED_PROPERTY
Definition: ncrypt.h:123
#define DWORD
Definition: nt_native.h:44
BYTE expected_data[64]
Definition: ncrypt.c:171
Definition: copy.c:22
Definition: parser.c:49
Definition: name.c:39
#define NTE_NOT_SUPPORTED
Definition: winerror.h:4288
#define NTE_NOT_FOUND
Definition: winerror.h:4264
#define NTE_BAD_FLAGS
Definition: winerror.h:4256

◆ check_property()

static void check_property ( int  line,
NCRYPT_KEY_HANDLE  key,
const struct expected_property *  property 
)
static

Definition at line 179 of file ncrypt.c.

180{
181 BYTE buffer[64] = {0};
183 unsigned int i;
184 DWORD size;
185
187
188 if (property->expected_status != ERROR_SUCCESS)
189 {
190 size = 0;
193 ok_(__FILE__, line)(ret == property->expected_status || broken(ret == property->broken_status),
194 "got unexpected return value %#lx\n", ret);
195 if (ret == ERROR_SUCCESS)
196 {
197 ok_(__FILE__, line)(size == property->expected_size, "got unexpected size %lu\n", size);
198
199 if (!wcscmp(property->name, NCRYPT_PROVIDER_HANDLE_PROPERTY))
200 NCryptFreeObject((NCRYPT_HANDLE)buffer);
201 }
202
203 goto done;
204 }
205
206 size = 0;
207 ret = NCryptGetProperty(key, property->name, NULL, 0, &size, 0);
208 todo_wine_if(property->todo)
209 ok_(__FILE__, line)(ret == property->expected_status || broken(ret == property->broken_status),
210 "got unexpected return value %#lx\n", ret);
211 if (ret != ERROR_SUCCESS)
212 goto done;
213 ok_(__FILE__, line)(size == property->expected_size, "got unexpected size %lu\n", size);
214
215 size = 0;
216 ret = NCryptGetProperty(key, property->name, buffer, sizeof(buffer), &size, 0);
217 ok_(__FILE__, line)(ret == property->expected_status, "got unexpected return value %#lx\n", ret);
218 ok_(__FILE__, line)(size == property->expected_size, "got unexpected size %lu\n", size);
219 if (ret == ERROR_SUCCESS && memcmp(property->expected_data, buffer, property->expected_size)
220 && broken(memcmp(property->broken_data, buffer, property->expected_size)))
221 {
222 for (i = 0; i < size; i ++)
223 {
224 ok_(__FILE__, line)(0, "%#04x \n", buffer[i]);
225 }
226 }
227
228done:
229 winetest_pop_context();
230}
#define broken(x)
Definition: atltest.h:178
#define ok_(x1, x2)
Definition: atltest.h:61
return
Definition: dirsup.c:529
void CDECL unexpected(void)
Definition: cpp.c:711
SECURITY_STATUS WINAPI NCryptGetProperty(NCRYPT_HANDLE handle, const WCHAR *name, BYTE *output, DWORD outsize, DWORD *result, DWORD flags)
Definition: main.c:386
return ret
Definition: mutex.c:147
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
#define wine_dbgstr_w
Definition: kernel32.h:34
#define todo_wine_if(is_todo)
Definition: minitest.h:81
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:539
LONG SECURITY_STATUS
Definition: ncrypt.h:31
BSTR name
Definition: locator.c:107
Definition: pdh_main.c:64
unsigned char BYTE
Definition: xxhash.c:193

◆ START_TEST()

START_TEST ( ncrypt  )

Definition at line 843 of file ncrypt.c.

844{
855}
static void test_finalize_key(void)
Definition: ncrypt.c:502
static void test_NCryptIsAlgSupported(void)
Definition: ncrypt.c:661
static void test_NCryptEncrypt(void)
Definition: ncrypt.c:737
static void test_verify_signature(void)
Definition: ncrypt.c:605
static void test_set_property(void)
Definition: ncrypt.c:414
static void test_NCryptExportKey(void)
Definition: ncrypt.c:812
static void test_free_object(void)
Definition: ncrypt.c:356
static void test_create_persisted_key(void)
Definition: ncrypt.c:465
static void test_get_property(void)
Definition: ncrypt.c:383
static void test_key_import_rsa(void)
Definition: ncrypt.c:303

◆ test_create_persisted_key()

static void test_create_persisted_key ( void  )
static

Definition at line 465 of file ncrypt.c.

466{
470
472 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
473
474 key = 0;
476 ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
477
478 ret = NCryptCreatePersistedKey(prov, &key, NULL, NULL, 0, 0);
480
482 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
483 ok(key, "got null handle\n");
484
485 check_properties(prov, key);
486
489
491 {
492 key = 0;
494 ok(ret == ERROR_SUCCESS || broken(ret == NTE_NOT_SUPPORTED) /* win 7 */, "got %#lx\n", ret);
495 if (ret == NTE_NOT_SUPPORTED) win_skip("broken, symmetric keys not supported.\n");
496 else ok(key, "got null handle\n");
497 }
498
499 NCryptFreeObject(prov);
500}
#define ok(value,...)
Definition: atltest.h:57
#define BCRYPT_RSA_ALGORITHM
Definition: bcrypt.h:117
#define BCRYPT_AES_ALGORITHM
Definition: bcrypt.h:96
#define NULL
Definition: types.h:112
SECURITY_STATUS WINAPI NCryptFinalizeKey(NCRYPT_KEY_HANDLE handle, DWORD flags)
Definition: main.c:301
SECURITY_STATUS WINAPI NCryptFreeObject(NCRYPT_HANDLE handle)
Definition: main.c:342
SECURITY_STATUS WINAPI NCryptCreatePersistedKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_HANDLE *key, const WCHAR *algid, const WCHAR *name, DWORD keyspec, DWORD flags)
Definition: main.c:184
SECURITY_STATUS WINAPI NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE *provider, const WCHAR *name, DWORD flags)
Definition: main.c:561
#define win_skip
Definition: minitest.h:67
#define todo_wine
Definition: minitest.h:80
#define check_properties(a, b)
Definition: ncrypt.c:232
ULONG_PTR NCRYPT_KEY_HANDLE
Definition: ncrypt.h:78
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define NTE_INVALID_HANDLE
Definition: winerror.h:4285
#define NTE_FAIL
Definition: winerror.h:4279
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1444

Referenced by START_TEST().

◆ test_finalize_key()

static void test_finalize_key ( void  )
static

Definition at line 502 of file ncrypt.c.

503{
507
509 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
510
512 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
513
515 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
516
518 ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
519
520 ret = NCryptFinalizeKey(0, 0);
521 ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
522
524}

Referenced by START_TEST().

◆ test_free_object()

static void test_free_object ( void  )
static

Definition at line 356 of file ncrypt.c.

357{
361 char *buf;
362
364 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
365
367 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
369 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
370
371 key = 0;
373 ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
374
375 buf = calloc(1, 50);
377 ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
378 free(buf);
379
380 NCryptFreeObject(prov);
381}
#define BCRYPT_RSAPUBLIC_BLOB
Definition: bcrypt.h:76
#define free
Definition: debug_ros.c:5
SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_HANDLE decrypt_key, const WCHAR *type, NCryptBufferDesc *params, NCRYPT_KEY_HANDLE *handle, BYTE *data, DWORD datasize, DWORD flags)
Definition: main.c:408
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static UCHAR rsa_key_blob[]
Definition: ncrypt.c:28
#define calloc
Definition: rosglue.h:14

Referenced by START_TEST().

◆ test_get_property()

static void test_get_property ( void  )
static

Definition at line 383 of file ncrypt.c.

384{
388 DWORD keylength, size;
389
391 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
392
393 ret = NCryptGetProperty(0, NCRYPT_LENGTH_PROPERTY, (BYTE *)&keylength, sizeof(keylength), &size, 0);
394 ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
395
397 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
398 check_properties(prov, key);
400
402 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
403 check_properties(prov, key);
405
407 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
408 check_properties(prov, key);
410
411 NCryptFreeObject(prov);
412}
#define BCRYPT_RSAPRIVATE_BLOB
Definition: bcrypt.h:77
#define BCRYPT_RSAFULLPRIVATE_BLOB
Definition: bcrypt.h:78
static UCHAR rsa_full_private_key_blob[]
Definition: ncrypt.c:69
static UCHAR rsa_private_key_blob[]
Definition: ncrypt.c:43

Referenced by START_TEST().

◆ test_key_import_rsa()

static void test_key_import_rsa ( void  )
static

Definition at line 303 of file ncrypt.c.

304{
308
309 prov = 0;
311 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
312 ok(prov, "got null handle\n");
313
314 key = 0;
316 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
317 ok(key, "got null handle\n");
319
320 key = 0;
322 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
323 ok(key, "got null handle\n");
325
327 ok(ret == NTE_BAD_FLAGS, "got %#lx\n", ret);
328
330 sizeof(invalid_rsa_key_blob), 0);
331 ok(ret == NTE_INVALID_PARAMETER, "got %#lx\n", ret);
332
334 ok(ret == NTE_INVALID_PARAMETER, "got %#lx\n", ret);
335
336 key = 0;
339 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret); /* I'm not sure why, but this returns success */
340 ok(key, "got null handle\n");
342
345 ok(ret == NTE_BAD_DATA, "got %#lx\n", ret);
346
348 ok(ret == NTE_BAD_DATA, "got %#lx\n", ret);
349
351 ok(ret == NTE_BAD_DATA, "got %#lx\n", ret);
352
353 NCryptFreeObject(prov);
354}
#define BCRYPT_PUBLIC_KEY_BLOB
Definition: bcrypt.h:81
static UCHAR invalid_rsa_key_blob[]
Definition: ncrypt.c:153
static UCHAR rsa_key_blob_with_invalid_bit_length[]
Definition: ncrypt.c:122
static UCHAR rsa_key_blob_with_invalid_publicexp_size[]
Definition: ncrypt.c:137
#define NTE_INVALID_PARAMETER
Definition: winerror.h:4286
#define NTE_BAD_DATA
Definition: winerror.h:4252

Referenced by START_TEST().

◆ test_NCryptEncrypt()

static void test_NCryptEncrypt ( void  )
static

Definition at line 737 of file ncrypt.c.

738{
742 BYTE *output_a;
743 BYTE *output_b;
744 DWORD output_size;
745
748
749 /* Test encrypt with invalid key handle */
751 &output_size, NCRYPT_PAD_PKCS1_FLAG);
752 ok(ret == NTE_INVALID_HANDLE, "got %lx\n", ret);
753
754 /* Test encrypt with a non finalized key */
756 &output_size, NCRYPT_PAD_PKCS1_FLAG);
758 ok(ret == NTE_BAD_KEY_STATE, "got %lx\n", ret);
759
761
762 /* Test encrypt with invalid flags */
764 &output_size, 51342);
765 ok(ret == NTE_BAD_FLAGS, "got %lx\n", ret);
766
767 /* Test no padding with RSA */
769 {
770 ret = NCryptEncrypt(key, data_to_encrypt, sizeof(data_to_encrypt), NULL, NULL, 0, &output_size,
772 ok(ret == ERROR_SUCCESS, "got %lx\n", ret);
773 ok(output_size == 128, "got %ld\n", output_size);
774
775 output_a = malloc(output_size);
776 ret = NCryptEncrypt(key, data_to_encrypt, sizeof(data_to_encrypt), NULL, output_a, output_size,
777 &output_size, NCRYPT_NO_PADDING_FLAG);
778 ok(ret == NTE_INVALID_PARAMETER, "got %lx\n", ret);
779 free(output_a);
780 }
781
782 /* Test output RSA with PKCS1. PKCS1 should append a random padding to the data, so the output should be different
783 * with each call. */
785 &output_size, NCRYPT_PAD_PKCS1_FLAG);
786 ok(ret == ERROR_SUCCESS, "got %lx\n", ret);
787 ok(output_size == 128, "got %ld\n", output_size);
788
789 output_a = malloc(output_size);
790 output_b = malloc(output_size);
791
792 ret = NCryptEncrypt(key, data_to_encrypt, sizeof(data_to_encrypt), NULL, output_a, 12,
793 &output_size, NCRYPT_PAD_PKCS1_FLAG);
794 ok(ret == NTE_BUFFER_TOO_SMALL, "got %lx\n", ret);
795
796 ret = NCryptEncrypt(key, data_to_encrypt, sizeof(data_to_encrypt), NULL, output_a, output_size,
797 &output_size, NCRYPT_PAD_PKCS1_FLAG);
798 ok(ret == ERROR_SUCCESS, "got %lx\n", ret);
799
800 ret = NCryptEncrypt(key, data_to_encrypt, sizeof(data_to_encrypt), NULL, output_b, output_size,
801 &output_size, NCRYPT_PAD_PKCS1_FLAG);
802 ok(ret == ERROR_SUCCESS, "got %lx\n", ret);
803 ok(memcmp(output_a, output_b, 128), "expected to have different outputs.\n");
804
806 free(output_a);
807 free(output_b);
808
809 NCryptFreeObject(prov);
810}
#define malloc
Definition: debug_ros.c:4
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
SECURITY_STATUS WINAPI NCryptEncrypt(NCRYPT_KEY_HANDLE key, BYTE *input, DWORD insize, void *padding, BYTE *output, DWORD outsize, DWORD *result, DWORD flags)
Definition: main.c:260
static UCHAR data_to_encrypt[12]
Definition: ncrypt.c:735
#define NCRYPT_PAD_PKCS1_FLAG
Definition: ncrypt.h:90
#define NCRYPT_NO_PADDING_FLAG
Definition: ncrypt.h:89
#define NTE_BAD_KEY_STATE
Definition: winerror.h:4258
#define NTE_BUFFER_TOO_SMALL
Definition: winerror.h:4287

Referenced by START_TEST().

◆ test_NCryptExportKey()

static void test_NCryptExportKey ( void  )
static

Definition at line 812 of file ncrypt.c.

813{
818 BYTE buffer[1024];
819
821 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
823 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
826 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
828
829 size = 0;
831 ok(ret == ERROR_SUCCESS, "got unexpected return value %lx\n", ret);
832 ok(size == 283, "got unexpected size %#lx\n", size);
833
834 size = 0;
836 ok(ret == ERROR_SUCCESS, "got unexpected return value %lx\n", ret);
837 ok(size == 603, "got unexpected size %#lx\n", size);
838
840 NCryptFreeObject(prov);
841}
WINBASEAPI _Check_return_ _Out_ AppPolicyProcessTerminationMethod * policy
Definition: appmodel.h:78
SECURITY_STATUS WINAPI NCryptExportKey(NCRYPT_KEY_HANDLE key, NCRYPT_KEY_HANDLE encrypt_key, const WCHAR *type, NCryptBufferDesc *params, BYTE *output, DWORD output_len, DWORD *ret_len, DWORD flags)
Definition: main.c:475
SECURITY_STATUS WINAPI NCryptSetProperty(NCRYPT_HANDLE handle, const WCHAR *name, BYTE *input, DWORD insize, DWORD flags)
Definition: main.c:576
#define NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG
Definition: ncrypt.h:101
#define NCRYPT_ALLOW_EXPORT_FLAG
Definition: ncrypt.h:100

Referenced by START_TEST().

◆ test_NCryptIsAlgSupported()

static void test_NCryptIsAlgSupported ( void  )
static

Definition at line 661 of file ncrypt.c.

662{
665
668 ok(ret == NTE_INVALID_HANDLE, "expected NTE_INVALID_HANDLE, got %#lx\n", ret);
669
670 ret = NCryptIsAlgSupported(prov, NULL, 0);
671 ok(ret == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER) || broken(ret == NTE_FAIL) /* win7 */, "got %#lx\n", ret);
672
674 ok(ret == NTE_BAD_FLAGS, "expected NTE_BAD_FLAGS, got %#lx\n", ret);
675
677 ok(ret == ERROR_SUCCESS, "expected BCRYPT_RSA_ALGORITHM to be supported, got %#lx\n", ret);
678
680 ok(ret == ERROR_SUCCESS, "expected BCRYPT_RSA_ALGORITHM to be supported, got %#lx\n", ret);
681
683 ok(ret == ERROR_SUCCESS || broken(ret == NTE_NOT_SUPPORTED) /* win7 */,
684 "expected BCRYPT_3DES_ALGORITHM to be supported, got %#lx\n", ret);
685
687 ok(ret == ERROR_SUCCESS || broken(ret == NTE_NOT_SUPPORTED) /* win7 */,
688 "expected BCRYPT_AES_ALGORITHM to be supported, got %#lx\n", ret);
689
691 ok(ret == ERROR_SUCCESS, "expected BCRYPT_ECDH_P256_ALGORITHM to be supported, got %#lx\n", ret);
692
694 ok(ret == ERROR_SUCCESS, "expected BCRYPT_ECDSA_P256_ALGORITHM to be supported, got %#lx\n", ret);
695
697 ok(ret == ERROR_SUCCESS, "expected BCRYPT_ECDSA_P384_ALGORITHM to be supported, got %#lx\n", ret);
698
700 ok(ret == ERROR_SUCCESS, "expected BCRYPT_DSA_ALGORITHM to be supported, got %#lx\n", ret);
701
702 /* Not supported */
704 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_SHA256_ALGORITHM to not be supported, got %#lx\n", ret);
705
707 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_SHA384_ALGORITHM to not be supported, got %#lx\n", ret);
708
710 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_SHA512_ALGORITHM to not be supported, got %#lx\n", ret);
711
713 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_SHA1_ALGORITHM to not be supported, got %#lx\n", ret);
714
716 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_MD5_ALGORITHM to not be supported, got %#lx\n", ret);
717
719 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_MD4_ALGORITHM to not be supported, got %#lx\n", ret);
720
722 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_MD2_ALGORITHM to not be supported, got %#lx\n", ret);
723
725 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_RSA_SIGN_ALGORITHM to not be supported, got %#lx\n", ret);
726
728 ok(ret == NTE_BAD_FLAGS, "expected NTE_BAD_FLAGS, got %#lx\n", ret);
729
731 ok(ret == NTE_NOT_SUPPORTED, "expected BCRYPT_RNG_ALGORITHM to not be supported, got %#lx\n", ret);
732 NCryptFreeObject(prov);
733}
#define BCRYPT_MD4_ALGORITHM
Definition: bcrypt.h:111
#define BCRYPT_3DES_ALGORITHM
Definition: bcrypt.h:95
#define BCRYPT_ECDSA_P384_ALGORITHM
Definition: bcrypt.h:108
#define BCRYPT_SHA512_ALGORITHM
Definition: bcrypt.h:122
#define BCRYPT_DSA_ALGORITHM
Definition: bcrypt.h:101
#define BCRYPT_MD2_ALGORITHM
Definition: bcrypt.h:110
#define BCRYPT_SHA256_ALGORITHM
Definition: bcrypt.h:120
#define BCRYPT_ECDSA_P256_ALGORITHM
Definition: bcrypt.h:107
#define BCRYPT_RNG_ALGORITHM
Definition: bcrypt.h:116
#define BCRYPT_ECDH_P256_ALGORITHM
Definition: bcrypt.h:103
#define BCRYPT_RSA_SIGN_ALGORITHM
Definition: bcrypt.h:118
#define BCRYPT_SHA384_ALGORITHM
Definition: bcrypt.h:121
#define BCRYPT_SHA1_ALGORITHM
Definition: bcrypt.h:119
#define BCRYPT_MD5_ALGORITHM
Definition: bcrypt.h:112
SECURITY_STATUS WINAPI NCryptIsAlgSupported(NCRYPT_PROV_HANDLE provider, const WCHAR *algid, DWORD flags)
Definition: main.c:502
#define NCRYPT_SILENT_FLAG
Definition: ncrypt.h:87

Referenced by START_TEST().

◆ test_set_property()

static void test_set_property ( void  )
static

Definition at line 414 of file ncrypt.c.

415{
419 DWORD keylength;
420
422 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
423
425 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
426
427 keylength = 2048;
428 ret = NCryptSetProperty(key, NCRYPT_LENGTH_PROPERTY, (BYTE *)&keylength, sizeof(keylength), 0);
429 ok(ret == ERROR_SUCCESS || broken(ret == NTE_INVALID_HANDLE), "got %#lx\n", ret);
430
431 ret = NCryptSetProperty(0, NCRYPT_LENGTH_PROPERTY, (BYTE *)&keylength, sizeof(keylength), 0);
432 ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
433
435 {
436 ret = NCryptSetProperty(key, NCRYPT_NAME_PROPERTY, (BYTE *)L"Key name", sizeof(L"Key name"), 0);
437 ok(ret == NTE_NOT_SUPPORTED, "got %#lx\n", ret);
438 }
440
441 key = 0;
443 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
444 ok(key, "got null handle\n");
445
446 keylength = 2048;
447 ret = NCryptSetProperty(key, NCRYPT_LENGTH_PROPERTY, (BYTE *)&keylength, sizeof(keylength), 0);
448 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
449
450 ret = NCryptSetProperty(key, NCRYPT_PROVIDER_HANDLE_PROPERTY, (BYTE *)&prov, sizeof(prov), 0);
451 ok(ret == NTE_NOT_SUPPORTED, "got %#lx\n", ret);
452
454 {
455 ret = NCryptSetProperty(key, NCRYPT_NAME_PROPERTY, (BYTE *)L"Key name", sizeof(L"Key name"), 0);
456 ok(ret == NTE_NOT_SUPPORTED, "got %#lx\n", ret);
457
458 ret = NCryptSetProperty(key, L"My Custom Property", (BYTE *)L"value", sizeof(L"value"), 0);
459 ok(ret == NTE_NOT_SUPPORTED, "got %#lx\n", ret);
460 }
462 NCryptFreeObject(prov);
463}

Referenced by START_TEST().

◆ test_verify_signature()

static void test_verify_signature ( void  )
static

Definition at line 605 of file ncrypt.c.

606{
609 BCRYPT_PKCS1_PADDING_INFO padinfo, invalid_padinfo;
611
613 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
614
616 sizeof(signature_pubkey_blob), 0);
617 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
618
622 ok(ret == ERROR_SUCCESS, "got %#lx\n", ret);
623
626 ok(ret == NTE_BAD_SIGNATURE, "got %#lx\n", ret);
627
629 sizeof(signature_pkcs1_sha256), 0);
630 ok(ret == NTE_INVALID_PARAMETER, "got %#lx\n", ret);
631
634 ok(ret == NTE_INVALID_HANDLE, "got %#lx\n", ret);
635
638 ok(ret == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER) || broken(ret == NTE_FAIL) /* win7 */, "got %#lx\n", ret);
639
642 todo_wine ok(ret == NTE_INVALID_PARAMETER, "got %#lx\n", ret);
643
646 ok(ret == HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER) || broken(ret == NTE_FAIL) /* win7 */, "got %#lx\n", ret);
647
650 ok(ret == NTE_INVALID_PARAMETER, "got %#lx\n", ret);
651
652 invalid_padinfo.pszAlgId = BCRYPT_MD5_ALGORITHM;
655 todo_wine ok(ret == NTE_INVALID_PARAMETER, "got %#lx\n", ret);
656
658 NCryptFreeObject(prov);
659}
SECURITY_STATUS WINAPI NCryptVerifySignature(NCRYPT_KEY_HANDLE handle, void *padding, BYTE *hash, DWORD hash_size, BYTE *signature, DWORD signature_size, DWORD flags)
Definition: main.c:602
static UCHAR signature_pkcs1_sha256[]
Definition: ncrypt.c:552
static UCHAR signature_pubkey_blob[]
Definition: ncrypt.c:526
static UCHAR invalid_signature[]
Definition: ncrypt.c:576
static UCHAR sha256_hash[]
Definition: ncrypt.c:600
#define NTE_BAD_SIGNATURE
Definition: winerror.h:4253

Referenced by START_TEST().

Variable Documentation

◆ data_to_encrypt

UCHAR data_to_encrypt[12] = "Hello world"
static

Definition at line 735 of file ncrypt.c.

Referenced by test_NCryptEncrypt().

◆ invalid_rsa_key_blob

UCHAR invalid_rsa_key_blob[]
static
Initial value:
= {
0x75, 0x59, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0xc7, 0x8f, 0xac, 0x2a, 0xce, 0xbf, 0xc9, 0x6c, 0x7b,
0x85, 0x74, 0x71, 0xbb, 0xff, 0xbb, 0x9b, 0x20, 0x03, 0x79, 0x17, 0x34,
0xe7, 0x26, 0x91, 0x5c, 0x1f, 0x1b, 0x03, 0x3d, 0x46, 0xdf, 0xb6, 0xf2,
0x10, 0x55, 0xf0, 0x39, 0x55, 0x0a, 0xe3, 0x9c, 0x0c, 0x63, 0xc2, 0x14,
0x03, 0x94, 0x51, 0x0d, 0xb4, 0x22, 0x09, 0xf2, 0x5c, 0xb2, 0xd1, 0xc3,
0xac, 0x6f, 0xa8, 0xc4, 0xac, 0xb8, 0xbc, 0x59, 0xe7, 0xed, 0x77, 0x6e,
0xb1, 0x80, 0x58, 0x7d, 0xb2, 0x94, 0x46, 0xe5, 0x00, 0xe2, 0xb7, 0x33,
0x48, 0x7a, 0xd3, 0x78, 0xe9, 0x26, 0x01, 0xc7, 0x00, 0x7b, 0x41, 0x6d,
0x94, 0x3a, 0xe1, 0x50, 0x2b, 0x9f, 0x6b, 0x1c, 0x08, 0xa3, 0xfc, 0x0a,
0x44, 0x81, 0x09, 0x41, 0x80, 0x23, 0x7b, 0xf6, 0x3f, 0xaf, 0x91, 0xa1,
0x87, 0x75, 0x33, 0x15, 0xb8, 0xde, 0x32, 0x30, 0xb4, 0x5e, 0xfd}

Definition at line 153 of file ncrypt.c.

Referenced by test_key_import_rsa().

◆ invalid_signature

UCHAR invalid_signature[]
static
Initial value:
= {
0x4f, 0x8f, 0x88, 0x43, 0xed, 0x9e, 0xe8, 0x75, 0x0f, 0xe7, 0x32, 0xab,
0x07, 0xcc, 0x6c, 0x8d, 0x56, 0xaa, 0x78, 0xf8, 0x43, 0x62, 0x4c, 0x0c,
0xd5, 0x45, 0x2c, 0x3d, 0x28, 0x6f, 0xbc, 0x8b, 0xc1, 0x9f, 0xfe, 0x33,
0x50, 0x4e, 0xd0, 0x6a, 0x83, 0xf8, 0x0e, 0xc8, 0x19, 0x59, 0xde, 0x25,
0xf0, 0x7b, 0x4e, 0x3d, 0x9d, 0xc7, 0xbf, 0x72, 0xc3, 0x26, 0x48, 0xb6,
0x19, 0x08, 0x3f, 0x05, 0xe8, 0x76, 0x2c, 0x11, 0x49, 0xfb, 0xa1, 0xc0,
0xae, 0x6e, 0x30, 0xf8, 0x10, 0x61, 0x9f, 0x53, 0xc6, 0xeb, 0x7c, 0x7c,
0x94, 0x5f, 0xca, 0xe5, 0x41, 0x40, 0xd6, 0x83, 0xa8, 0x4a, 0x45, 0x5c,
0x77, 0x69, 0xf2, 0x89, 0xe9, 0xf7, 0x81, 0xa1, 0xae, 0x77, 0xf5, 0xec,
0x41, 0x4b, 0xfc, 0x82, 0x7f, 0xee, 0x4e, 0x5b, 0x43, 0xdd, 0xcc, 0xe8,
0x90, 0x12, 0xf0, 0x9a, 0xd0, 0xbc, 0x56, 0xd8, 0xeb, 0xd6, 0xfc, 0x80,
0x48, 0x26, 0x8c, 0x63, 0x5c, 0x55, 0xd9, 0x6c, 0xb5, 0x10, 0xc1, 0xab,
0x98, 0x3c, 0xe1, 0x25, 0x13, 0x4e, 0xc2, 0xdc, 0xd5, 0x4a, 0x25, 0xe5,
0xc7, 0x9f, 0xfc, 0xf8, 0x53, 0x53, 0x12, 0x4c, 0xc1, 0x6c, 0x67, 0xa9,
0x9e, 0x6e, 0x88, 0x2e, 0x93, 0xa3, 0x3f, 0x2d, 0xd3, 0xc5, 0xf4, 0x25,
0xe2, 0x0f, 0x8f, 0xc0, 0x2b, 0x30, 0x94, 0x9d, 0xc0, 0x09, 0x31, 0x6c,
0x19, 0xf7, 0x2e, 0x72, 0x6b, 0xb3, 0xf6, 0x78, 0x91, 0xca, 0x95, 0x28,
0x9f, 0xf6, 0xd0, 0x77, 0x1c, 0x73, 0xff, 0x30, 0xe7, 0x02, 0xc3, 0xc8,
0x0e, 0x95, 0x4f, 0x02, 0x96, 0xc5, 0xa9, 0x02, 0xb8, 0xaa, 0x97, 0xac,
0x37, 0x47, 0xa9, 0x6d, 0xcb, 0x25, 0xb3, 0x8d, 0x20, 0xc5, 0xb6, 0x49,
0xd8, 0xaf, 0x1a, 0xad, 0x62, 0x8c, 0x79, 0x60, 0x73, 0x8d, 0x46, 0x1e,
0xe5, 0x23, 0x39, 0x44}

Definition at line 576 of file ncrypt.c.

Referenced by test_verify_signature().

◆ rsa_full_private_key_blob

UCHAR rsa_full_private_key_blob[]
static

Definition at line 69 of file ncrypt.c.

Referenced by test_get_property().

◆ rsa_key_blob

UCHAR rsa_key_blob[]
static
Initial value:
= {
0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0xc7, 0x8f, 0xac, 0x2a, 0xce, 0xbf, 0xc9, 0x6c, 0x7b,
0x85, 0x74, 0x71, 0xbb, 0xff, 0xbb, 0x9b, 0x20, 0x03, 0x79, 0x17, 0x34,
0xe7, 0x26, 0x91, 0x5c, 0x1f, 0x1b, 0x03, 0x3d, 0x46, 0xdf, 0xb6, 0xf2,
0x10, 0x55, 0xf0, 0x39, 0x55, 0x0a, 0xe3, 0x9c, 0x0c, 0x63, 0xc2, 0x14,
0x03, 0x94, 0x51, 0x0d, 0xb4, 0x22, 0x09, 0xf2, 0x5c, 0xb2, 0xd1, 0xc3,
0xac, 0x6f, 0xa8, 0xc4, 0xac, 0xb8, 0xbc, 0x59, 0xe7, 0xed, 0x77, 0x6e,
0xb1, 0x80, 0x58, 0x7d, 0xb2, 0x94, 0x46, 0xe5, 0x00, 0xe2, 0xb7, 0x33,
0x48, 0x7a, 0xd3, 0x78, 0xe9, 0x26, 0x01, 0xc7, 0x00, 0x7b, 0x41, 0x6d,
0x94, 0x3a, 0xe1, 0x50, 0x2b, 0x9f, 0x6b, 0x1c, 0x08, 0xa3, 0xfc, 0x0a,
0x44, 0x81, 0x09, 0x41, 0x80, 0x23, 0x7b, 0xf6, 0x3f, 0xaf, 0x91, 0xa1,
0x87, 0x75, 0x33, 0x15, 0xb8, 0xde, 0x32, 0x30, 0xb4, 0x5e, 0xfd}

Definition at line 28 of file ncrypt.c.

Referenced by test_free_object(), test_get_property(), test_key_import_rsa(), and test_set_property().

◆ rsa_key_blob_with_invalid_bit_length

UCHAR rsa_key_blob_with_invalid_bit_length[]
static
Initial value:
= {
0x52, 0x53, 0x41, 0x31, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0xc7, 0x8f, 0xac, 0x2a, 0xce, 0xbf, 0xc9, 0x6c, 0x7b,
0x85, 0x74, 0x71, 0xbb, 0xff, 0xbb, 0x9b, 0x20, 0x03, 0x79, 0x17, 0x34,
0xe7, 0x26, 0x91, 0x5c, 0x1f, 0x1b, 0x03, 0x3d, 0x46, 0xdf, 0xb6, 0xf2,
0x10, 0x55, 0xf0, 0x39, 0x55, 0x0a, 0xe3, 0x9c, 0x0c, 0x63, 0xc2, 0x14,
0x03, 0x94, 0x51, 0x0d, 0xb4, 0x22, 0x09, 0xf2, 0x5c, 0xb2, 0xd1, 0xc3,
0xac, 0x6f, 0xa8, 0xc4, 0xac, 0xb8, 0xbc, 0x59, 0xe7, 0xed, 0x77, 0x6e,
0xb1, 0x80, 0x58, 0x7d, 0xb2, 0x94, 0x46, 0xe5, 0x00, 0xe2, 0xb7, 0x33,
0x48, 0x7a, 0xd3, 0x78, 0xe9, 0x26, 0x01, 0xc7, 0x00, 0x7b, 0x41, 0x6d,
0x94, 0x3a, 0xe1, 0x50, 0x2b, 0x9f, 0x6b, 0x1c, 0x08, 0xa3, 0xfc, 0x0a,
0x44, 0x81, 0x09, 0x41, 0x80, 0x23, 0x7b, 0xf6, 0x3f, 0xaf, 0x91, 0xa1,
0x87, 0x75, 0x33, 0x15, 0xb8, 0xde, 0x32, 0x30, 0xb4, 0x5e, 0xfd}

Definition at line 122 of file ncrypt.c.

Referenced by test_key_import_rsa().

◆ rsa_key_blob_with_invalid_publicexp_size

UCHAR rsa_key_blob_with_invalid_publicexp_size[]
static
Initial value:
= {
0x52, 0x53, 0x41, 0x31, 0x00, 0x04, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0xc7, 0x8f, 0xac, 0x2a, 0xce, 0xbf, 0xc9, 0x6c, 0x7b,
0x85, 0x74, 0x71, 0xbb, 0xff, 0xbb, 0x9b, 0x20, 0x03, 0x79, 0x17, 0x34,
0xe7, 0x26, 0x91, 0x5c, 0x1f, 0x1b, 0x03, 0x3d, 0x46, 0xdf, 0xb6, 0xf2,
0x10, 0x55, 0xf0, 0x39, 0x55, 0x0a, 0xe3, 0x9c, 0x0c, 0x63, 0xc2, 0x14,
0x03, 0x94, 0x51, 0x0d, 0xb4, 0x22, 0x09, 0xf2, 0x5c, 0xb2, 0xd1, 0xc3,
0xac, 0x6f, 0xa8, 0xc4, 0xac, 0xb8, 0xbc, 0x59, 0xe7, 0xed, 0x77, 0x6e,
0xb1, 0x80, 0x58, 0x7d, 0xb2, 0x94, 0x46, 0xe5, 0x00, 0xe2, 0xb7, 0x33,
0x48, 0x7a, 0xd3, 0x78, 0xe9, 0x26, 0x01, 0xc7, 0x00, 0x7b, 0x41, 0x6d,
0x94, 0x3a, 0xe1, 0x50, 0x2b, 0x9f, 0x6b, 0x1c, 0x08, 0xa3, 0xfc, 0x0a,
0x44, 0x81, 0x09, 0x41, 0x80, 0x23, 0x7b, 0xf6, 0x3f, 0xaf, 0x91, 0xa1,
0x87, 0x75, 0x33, 0x15, 0xb8, 0xde, 0x32, 0x30, 0xb4, 0x5e, 0xfd}

Definition at line 137 of file ncrypt.c.

Referenced by test_key_import_rsa().

◆ rsa_private_key_blob

UCHAR rsa_private_key_blob[]
static
Initial value:
= {
0x52, 0x53, 0x41, 0x32, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0xaf, 0xc0, 0x68, 0x21, 0x76, 0xd7, 0x46, 0xf8, 0x23,
0x78, 0x94, 0x22, 0xa3, 0x0f, 0x4e, 0xe8, 0xc6, 0x6a, 0x33, 0xdc, 0xbf,
0x44, 0x6c, 0xb6, 0x95, 0x17, 0x78, 0x1e, 0x75, 0xca, 0xdc, 0x66, 0xe4,
0x87, 0xbe, 0x91, 0xbf, 0xb3, 0xc0, 0xa5, 0x16, 0xa1, 0xb7, 0xfe, 0x4c,
0x67, 0xaa, 0x03, 0x38, 0xe7, 0x13, 0x65, 0xfb, 0xb6, 0x4c, 0x52, 0x29,
0xa4, 0xc4, 0x92, 0x34, 0xcd, 0x81, 0xa5, 0x0b, 0x7f, 0x5f, 0x56, 0xbf,
0xa7, 0xf8, 0xec, 0x9a, 0xe7, 0xb3, 0x93, 0xba, 0x00, 0xe9, 0x48, 0x7a,
0xf7, 0x04, 0x65, 0xa3, 0x14, 0x8d, 0x08, 0x78, 0xd8, 0x16, 0x5e, 0x82,
0xeb, 0xd8, 0xea, 0x3c, 0xec, 0xcc, 0x64, 0x47, 0x97, 0x69, 0x43, 0x17,
0x5d, 0x25, 0xd9, 0xb8, 0xdf, 0xfc, 0x80, 0x16, 0xbe, 0xbb, 0xa8, 0xe4,
0xbf, 0x6a, 0x2f, 0xea, 0x9c, 0xe5, 0x58, 0x8a, 0xf4, 0x2b, 0xe5, 0xcf,
0x67, 0x26, 0xe2, 0xeb, 0x92, 0x88, 0xde, 0x52, 0xee, 0x43, 0x44, 0x14,
0x6d, 0xf7, 0x46, 0x9c, 0x87, 0xa8, 0x96, 0x85, 0xda, 0x19, 0xc3, 0x57,
0x95, 0x09, 0x8d, 0xa2, 0x4e, 0xcd, 0x84, 0x67, 0x8e, 0x2c, 0x2d, 0x16,
0xb0, 0xb4, 0xb4, 0x66, 0xcc, 0x7b, 0x7f, 0xaa, 0x2b, 0x14, 0x17, 0x4c,
0x68, 0x4a, 0xa2, 0xd3, 0xfc, 0xe0, 0xb9, 0xcd, 0xa4, 0xbb, 0x44, 0x0b,
0x84, 0xa7, 0x13, 0xd8, 0xee, 0xae, 0x8e, 0xdb, 0x0b, 0xd3, 0xc5, 0xc5,
0x3b, 0xfd, 0x6c, 0xb0, 0x92, 0x14, 0xf0, 0x7b, 0xa7, 0x37, 0xd6, 0x21,
0x73, 0x5d, 0x80, 0x9a, 0x49, 0x71, 0x2f, 0xc9, 0x05, 0xa5, 0x74, 0x81,
0xc9, 0xd5, 0x2a, 0x6a, 0x7f, 0xe8, 0x8e, 0xa9, 0x7b, 0x79, 0x9e, 0x46,
0x51, 0xe7, 0x08, 0xa1, 0x75, 0x51, 0x75, 0x7a, 0x4a, 0x43, 0x0e, 0x5b,
0x5a, 0xb8, 0x1b, 0xa3, 0x85, 0x68, 0x27}

Definition at line 43 of file ncrypt.c.

Referenced by test_get_property().

◆ sha256_hash

UCHAR sha256_hash[]
static
Initial value:
= {
0x27, 0x51, 0x8b, 0xa9, 0x68, 0x30, 0x11, 0xf6, 0xb3, 0x96, 0x07, 0x2c,
0x05, 0xf6, 0x65, 0x6d, 0x04, 0xf5, 0xfb, 0xc3, 0x78, 0x7c, 0xf9, 0x24,
0x90, 0xec, 0x60, 0x6e, 0x50, 0x92, 0xe3, 0x26}

Definition at line 600 of file ncrypt.c.

Referenced by test_verify_signature().

◆ signature_pkcs1_sha256

UCHAR signature_pkcs1_sha256[]
static
Initial value:
= {
0xad, 0x3d, 0x2f, 0x31, 0x87, 0xba, 0x5b, 0xdc, 0x84, 0x95, 0x77, 0x68,
0xf9, 0x9c, 0xd2, 0x38, 0x5b, 0x9f, 0x09, 0xc3, 0x8e, 0x9e, 0x8e, 0x8d,
0x49, 0x56, 0x31, 0x09, 0x55, 0xc6, 0xd2, 0x1a, 0xb3, 0x00, 0x71, 0x60,
0x84, 0x38, 0xf7, 0x1b, 0xc0, 0x43, 0x87, 0x31, 0x2d, 0xcc, 0xf2, 0x49,
0x5f, 0x21, 0x8e, 0x77, 0x16, 0x57, 0xd7, 0xe9, 0x37, 0x3a, 0xe9, 0x91,
0x5b, 0xc5, 0xea, 0x34, 0xb5, 0xf7, 0x4d, 0xaa, 0x65, 0x06, 0xef, 0xc6,
0x14, 0xfa, 0xa7, 0x1e, 0xe5, 0xc6, 0x18, 0xfe, 0x06, 0x64, 0xe7, 0x6e,
0x11, 0x83, 0x03, 0x4c, 0x91, 0x47, 0x60, 0x88, 0x12, 0x0c, 0x5e, 0xcc,
0x3a, 0x93, 0x2f, 0x5c, 0x57, 0x5b, 0x66, 0x55, 0xa3, 0xe5, 0xf4, 0x3c,
0x6f, 0xe9, 0xd8, 0xfd, 0xcc, 0x19, 0xc8, 0xf8, 0x13, 0x21, 0x3d, 0x29,
0xee, 0x3c, 0xb2, 0xb4, 0x3f, 0x36, 0xd8, 0x82, 0xb1, 0xa9, 0x34, 0x89,
0x2a, 0x7a, 0x42, 0x4a, 0x13, 0x0a, 0x0b, 0x50, 0xbe, 0x43, 0xa8, 0x2c,
0x5a, 0x86, 0x65, 0x9f, 0xab, 0x86, 0x25, 0x44, 0xbb, 0x6b, 0xca, 0x04,
0xca, 0xa5, 0xe7, 0x8e, 0xe2, 0x1d, 0xa8, 0x31, 0x90, 0x85, 0x6a, 0xd9,
0xaf, 0x67, 0x8c, 0x1a, 0x13, 0xea, 0xa8, 0xfd, 0x3d, 0xc0, 0xb0, 0x3f,
0xde, 0x6a, 0xc9, 0x65, 0xeb, 0x0a, 0xa6, 0x9b, 0xfc, 0x97, 0x0a, 0x72,
0xaf, 0x04, 0xde, 0x3f, 0xcb, 0xac, 0x97, 0x6e, 0xfa, 0xbb, 0xd8, 0x6e,
0xad, 0x0d, 0x10, 0xc6, 0x34, 0x18, 0x50, 0xb9, 0x12, 0xd4, 0x6b, 0xd5,
0x3d, 0x9d, 0xfb, 0x31, 0x8d, 0x96, 0x39, 0x4d, 0x20, 0x91, 0x40, 0x06,
0xca, 0xe6, 0x33, 0x73, 0x76, 0x2a, 0xe3, 0xab, 0xaf, 0x9d, 0xe9, 0x4e,
0xb7, 0xe0, 0x4b, 0x45, 0x23, 0x07, 0xe9, 0xe2, 0xab, 0xdc, 0x9f, 0x5a,
0xed, 0xbe, 0x76, 0x27}

Definition at line 552 of file ncrypt.c.

Referenced by test_verify_signature().

◆ signature_pubkey_blob

UCHAR signature_pubkey_blob[]
static
Initial value:
= {
0x52, 0x53, 0x41, 0x31, 0x00, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x01, 0xb4, 0xdb, 0x15, 0x24, 0xd0, 0x9a, 0xf4, 0xa3, 0x22,
0x04, 0xbe, 0xbd, 0xda, 0xb4, 0x3b, 0x1f, 0x9d, 0x5f, 0x2a, 0x3e, 0xe7,
0x42, 0xd7, 0xfa, 0xbc, 0xeb, 0x4e, 0xba, 0xcf, 0x92, 0x5d, 0x42, 0x0e,
0xc0, 0xb0, 0x0f, 0xcc, 0xc3, 0x03, 0x69, 0x23, 0xb9, 0xc2, 0x07, 0xf7,
0xf5, 0x19, 0xef, 0x9f, 0xb6, 0xd4, 0x6d, 0x35, 0x0d, 0x4c, 0x3a, 0x2b,
0x37, 0x9d, 0x4d, 0x61, 0xce, 0x30, 0x33, 0x27, 0xe4, 0x9a, 0xca, 0x23,
0xd6, 0x8f, 0x90, 0x33, 0xba, 0x5b, 0x16, 0xab, 0xa6, 0xda, 0x7a, 0x16,
0x8e, 0xae, 0xf9, 0x6f, 0x29, 0xe2, 0xf1, 0x3d, 0xf0, 0xb6, 0xb4, 0x70,
0xc0, 0x6d, 0xfc, 0x73, 0xf1, 0x3e, 0xdf, 0x02, 0x2c, 0xab, 0x24, 0x7a,
0xd8, 0x8b, 0xcf, 0x63, 0xd0, 0x1a, 0x76, 0xb3, 0x11, 0x22, 0x5d, 0xf6,
0x72, 0xb5, 0xd1, 0x6b, 0x83, 0xcd, 0x63, 0x5d, 0x3d, 0x03, 0xa2, 0xe0,
0x36, 0xe8, 0x54, 0xe9, 0x6f, 0x04, 0xb3, 0x1a, 0xdf, 0x35, 0xd7, 0x01,
0x57, 0xc7, 0x8d, 0x81, 0x4b, 0x39, 0x0c, 0x92, 0x71, 0x0b, 0x7d, 0x05,
0xb4, 0xa4, 0xb4, 0xd4, 0x73, 0x55, 0x85, 0x19, 0xd5, 0x37, 0x7f, 0xcd,
0x81, 0xd3, 0xf2, 0x62, 0x60, 0xfb, 0x6a, 0x1a, 0xda, 0xb4, 0x83, 0xfa,
0x87, 0xac, 0x51, 0x3a, 0xb4, 0xc2, 0x03, 0xd3, 0xc6, 0xf0, 0x20, 0xca,
0x10, 0xfd, 0xeb, 0xd8, 0x85, 0xb9, 0x74, 0x29, 0x83, 0xda, 0xa2, 0xee,
0xcc, 0xf4, 0xf6, 0x18, 0xbc, 0x84, 0x92, 0xf5, 0xdb, 0x71, 0x14, 0xb9,
0x62, 0x54, 0x4b, 0x64, 0x58, 0x95, 0xbc, 0x69, 0xc1, 0xcd, 0xac, 0x4b,
0x7c, 0x1d, 0xc4, 0xe7, 0x6c, 0x44, 0x80, 0x5e, 0x88, 0x3a, 0x9c, 0xbd,
0xd5, 0xa5, 0x2f, 0xa6, 0x73, 0x65, 0x48, 0x00, 0x5e, 0xfd, 0xe9, 0x4e,
0xd7, 0x6c, 0x59, 0x47, 0x9b, 0xd1, 0x9d}

Definition at line 526 of file ncrypt.c.

Referenced by test_verify_signature().