ReactOS 0.4.17-dev-1190-g4c812f4
implglue.h File Reference
#include "symcrypt.h"
#include "symcrypt_low_level.h"
Include dependency graph for implglue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rsa_key
 
union  tagKEY_CONTEXT
 
struct  hash< _Key >
 

Macros

#define RSAENH_MAX_HASH_SIZE   104
 

Typedefs

typedef union tagKEY_CONTEXT KEY_CONTEXT
 

Functions

BOOL init_hash_impl (ALG_ID algid, struct hash *hash)
 
static void update_hash_impl (struct hash *hash, const BYTE *data, DWORD len)
 
static void finalize_hash_impl (struct hash *hash, BYTE *hash_value, DWORD hash_size)
 
static DWORD hash_len_impl (const struct hash *hash)
 
static DWORD hash_block_len_impl (const struct hash *hash)
 
BOOL new_key_impl (ALG_ID algid, KEY_CONTEXT *ctx, DWORD keylen)
 
BOOL free_key_impl (ALG_ID algid, KEY_CONTEXT *ctx)
 
BOOL setup_key_impl (ALG_ID algid, KEY_CONTEXT *ctx, DWORD keylen, DWORD effective_keylen, DWORD saltlen, const BYTE *keyvalue)
 
BOOL duplicate_key_impl (ALG_ID algid, const KEY_CONTEXT *src, KEY_CONTEXT *dst)
 
BOOL encrypt_block_impl (ALG_ID algid, KEY_CONTEXT *ctx, const BYTE *in, BYTE *out)
 
BOOL decrypt_block_impl (ALG_ID algid, KEY_CONTEXT *ctx, const BYTE *in, BYTE *out)
 
BOOL encrypt_stream_impl (ALG_ID algid, KEY_CONTEXT *ctx, BYTE *inout, DWORD len)
 
BOOL sign_hash_impl (KEY_CONTEXT *ctx, const BYTE *in, BYTE *out)
 
BOOL verify_signature_impl (KEY_CONTEXT *ctx, const BYTE *in, BYTE *out)
 
BOOL export_public_key_impl (const KEY_CONTEXT *ctx, BYTE *dst, DWORD *pubexp)
 
BOOL import_public_key_impl (ALG_ID algid, const BYTE *src, DWORD keylen, DWORD pubexp, KEY_CONTEXT *ctx)
 
BOOL export_private_key_impl (const KEY_CONTEXT *ctx, BYTE *dst, DWORD *pubexp)
 
BOOL import_private_key_impl (ALG_ID algid, const BYTE *src, DWORD keylen, DWORD pubexp, KEY_CONTEXT *ctx)
 

Macro Definition Documentation

◆ RSAENH_MAX_HASH_SIZE

#define RSAENH_MAX_HASH_SIZE   104

Definition at line 30 of file implglue.h.

Typedef Documentation

◆ KEY_CONTEXT

typedef union tagKEY_CONTEXT KEY_CONTEXT

Function Documentation

◆ decrypt_block_impl()

BOOL decrypt_block_impl ( ALG_ID  algid,
KEY_CONTEXT *  ctx,
const BYTE *  in,
BYTE *  out 
)

Definition at line 395 of file implglue.c.

396{
397 switch (algid)
398 {
399 case CALG_RC2:
400 SymCryptRc2Decrypt( &ctx->rc2, in, out );
401 break;
402 case CALG_3DES:
403 case CALG_3DES_112:
404 SymCrypt3DesDecrypt( &ctx->des3, in, out );
405 break;
406 case CALG_DES:
407 SymCryptDesDecrypt( &ctx->des, in, out );
408 break;
409 case CALG_AES:
410 case CALG_AES_128:
411 case CALG_AES_192:
412 case CALG_AES_256:
413 SymCryptAesDecrypt( &ctx->aes, in, out );
414 break;
415 case CALG_RSA_KEYX:
416 case CALG_RSA_SIGN:
417 case CALG_SSL3_SHAMD5:
419 default:
421 return FALSE;
422 }
423 return TRUE;
424}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
GLuint in
Definition: glext.h:9616
static BOOL rsa_decrypt(const SYMCRYPT_RSAKEY *key, const BYTE *in, SYMCRYPT_NUMBER_FORMAT in_format, BYTE *out, SYMCRYPT_NUMBER_FORMAT out_format)
Definition: implglue.c:332
algid
VOID SYMCRYPT_CALL SymCryptAesDecrypt(_In_ PCSYMCRYPT_AES_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_AES_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_AES_BLOCK_SIZE) PBYTE pbDst)
Definition: aes-default.c:134
VOID SYMCRYPT_CALL SymCryptRc2Decrypt(_In_ PCSYMCRYPT_RC2_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_RC2_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_RC2_BLOCK_SIZE) PBYTE pbDst)
Definition: rc2.c:330
VOID SYMCRYPT_CALL SymCryptDesDecrypt(_In_ PCSYMCRYPT_DES_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_DES_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_DES_BLOCK_SIZE) PBYTE pbDst)
Definition: 3des.c:152
@ SYMCRYPT_NUMBER_FORMAT_MSB_FIRST
Definition: symcrypt.h:7017
@ SYMCRYPT_NUMBER_FORMAT_LSB_FIRST
Definition: symcrypt.h:7016
VOID SYMCRYPT_CALL SymCrypt3DesDecrypt(_In_ PCSYMCRYPT_3DES_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_3DES_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_3DES_BLOCK_SIZE) PBYTE pbDst)
Definition: 3des.c:478
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define CALG_RC2
Definition: wincrypt.h:2083
#define CALG_AES_128
Definition: wincrypt.h:2087
#define CALG_AES_192
Definition: wincrypt.h:2088
#define CALG_RSA_SIGN
Definition: wincrypt.h:2069
#define CALG_3DES_112
Definition: wincrypt.h:2085
#define CALG_AES
Definition: wincrypt.h:2090
#define CALG_RSA_KEYX
Definition: wincrypt.h:2080
#define CALG_AES_256
Definition: wincrypt.h:2089
#define CALG_3DES
Definition: wincrypt.h:2084
#define CALG_SSL3_SHAMD5
Definition: wincrypt.h:2062
#define CALG_DES
Definition: wincrypt.h:2082
#define NTE_BAD_ALGID
Definition: winerror.h:4255

Referenced by import_symmetric_key(), and RSAENH_CPDecrypt().

◆ duplicate_key_impl()

BOOL duplicate_key_impl ( ALG_ID  algid,
const KEY_CONTEXT *  src,
KEY_CONTEXT *  dst 
)

Definition at line 183 of file implglue.c.

184{
185 switch (algid)
186 {
187 case CALG_RC4:
188 case CALG_RC2:
189 case CALG_3DES:
190 case CALG_3DES_112:
191 case CALG_DES:
192 *dst = *src;
193 break;
194 case CALG_AES:
195 case CALG_AES_128:
196 case CALG_AES_192:
197 case CALG_AES_256:
198 /* SYMCRYPT_AES_EXPANDED_KEY contains pointers into its own RoundKey
199 * array, so it cannot be copied by assignment. */
200 SymCryptAesKeyCopy( &src->aes, &dst->aes );
201 break;
202 case CALG_RSA_KEYX:
203 case CALG_RSA_SIGN:
204 {
205 BYTE *blob;
206 DWORD pubexp, keylen = SymCryptRsakeySizeofModulus( src->rsa.key );
207 BOOLEAN private = SymCryptRsakeyHasPrivateKey( src->rsa.key );
208
209 if (!(dst->rsa.key = alloc_rsa_key( keylen * 8, private )) || !(blob = malloc( keylen * 2 )))
210 {
212 return FALSE;
213 }
214 if (private)
215 {
216 if (!export_private_key_impl( src, blob, &pubexp ) ||
217 !import_private_key_impl( algid, blob, keylen, pubexp, dst ))
218 {
219 free( blob );
220 return FALSE;
221 }
222 }
223 else
224 {
225 if (!export_public_key_impl( src, blob, &pubexp ) ||
226 !import_public_key_impl( algid, blob, keylen, pubexp, dst ))
227 {
228 free( blob );
229 return FALSE;
230 }
231 }
232 dst->rsa.flags = src->rsa.flags;
233 free( blob );
234 break;
235 }
236 default:
238 return FALSE;
239 }
240 return TRUE;
241}
unsigned char BOOLEAN
Definition: actypes.h:127
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
BOOL import_public_key_impl(ALG_ID algid, const BYTE *src, DWORD keylen, DWORD pubexp, KEY_CONTEXT *ctx)
Definition: implglue.c:470
BOOL export_public_key_impl(const KEY_CONTEXT *ctx, BYTE *dst, DWORD *pubexp)
Definition: implglue.c:450
BOOL import_private_key_impl(ALG_ID algid, const BYTE *src, DWORD keylen, DWORD pubexp, KEY_CONTEXT *ctx)
Definition: implglue.c:533
BOOL export_private_key_impl(const KEY_CONTEXT *ctx, BYTE *dst, DWORD *pubexp)
Definition: implglue.c:493
static SYMCRYPT_RSAKEY * alloc_rsa_key(DWORD bitlen, BOOL private)
Definition: implglue.c:84
Definition: image.c:229
UINT32 SYMCRYPT_CALL SymCryptRsakeySizeofModulus(_In_ PCSYMCRYPT_RSAKEY pkRsakey)
Definition: rsakey.c:264
BOOLEAN SYMCRYPT_CALL SymCryptRsakeyHasPrivateKey(_In_ PCSYMCRYPT_RSAKEY pkRsakey)
Definition: rsakey.c:257
VOID SYMCRYPT_CALL SymCryptAesKeyCopy(_In_ PCSYMCRYPT_AES_EXPANDED_KEY pSrc, _Out_ PSYMCRYPT_AES_EXPANDED_KEY pDst)
Definition: aes-key.c:240
#define CALG_RC4
Definition: wincrypt.h:2091
#define NTE_FAIL
Definition: winerror.h:4279
unsigned char BYTE
Definition: xxhash.c:193

Referenced by RSAENH_CPCreateHash(), and RSAENH_CPDuplicateKey().

◆ encrypt_block_impl()

BOOL encrypt_block_impl ( ALG_ID  algid,
KEY_CONTEXT *  ctx,
const BYTE *  in,
BYTE *  out 
)

Definition at line 301 of file implglue.c.

302{
303 switch (algid)
304 {
305 case CALG_RC2:
306 SymCryptRc2Encrypt( &ctx->rc2, in, out );
307 break;
308 case CALG_3DES:
309 case CALG_3DES_112:
310 SymCrypt3DesEncrypt( &ctx->des3, in, out );
311 break;
312 case CALG_DES:
313 SymCryptDesEncrypt( &ctx->des, in, out );
314 break;
315 case CALG_AES:
316 case CALG_AES_128:
317 case CALG_AES_192:
318 case CALG_AES_256:
319 SymCryptAesEncrypt( &ctx->aes, in, out );
320 break;
321 case CALG_RSA_KEYX:
322 case CALG_RSA_SIGN:
323 case CALG_SSL3_SHAMD5:
325 default:
327 return FALSE;
328 }
329 return TRUE;
330}
static BOOL rsa_encrypt(const SYMCRYPT_RSAKEY *key, const BYTE *in, SYMCRYPT_NUMBER_FORMAT in_format, BYTE *out, SYMCRYPT_NUMBER_FORMAT out_format)
Definition: implglue.c:263
VOID SYMCRYPT_CALL SymCryptDesEncrypt(_In_ PCSYMCRYPT_DES_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_DES_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_DES_BLOCK_SIZE) PBYTE pbDst)
Definition: 3des.c:142
VOID SYMCRYPT_CALL SymCryptRc2Encrypt(_In_ PCSYMCRYPT_RC2_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_RC2_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_RC2_BLOCK_SIZE) PBYTE pbDst)
Definition: rc2.c:234
VOID SYMCRYPT_CALL SymCryptAesEncrypt(_In_ PCSYMCRYPT_AES_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_AES_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_AES_BLOCK_SIZE) PBYTE pbDst)
Definition: aes-default.c:95
VOID SYMCRYPT_CALL SymCrypt3DesEncrypt(_In_ PCSYMCRYPT_3DES_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_3DES_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_3DES_BLOCK_SIZE) PBYTE pbDst)
Definition: 3des.c:358

Referenced by block_encrypt(), crypt_export_simple(), RSAENH_CPDecrypt(), and RSAENH_CPEncrypt().

◆ encrypt_stream_impl()

BOOL encrypt_stream_impl ( ALG_ID  algid,
KEY_CONTEXT *  ctx,
BYTE *  inout,
DWORD  len 
)

Definition at line 436 of file implglue.c.

437{
438 switch (algid)
439 {
440 case CALG_RC4:
442 break;
443 default:
445 return FALSE;
446 }
447 return TRUE;
448}
GLenum GLsizei len
Definition: glext.h:6722
Definition: parse.h:23
VOID SYMCRYPT_CALL SymCryptRc4Crypt(_Inout_ PSYMCRYPT_RC4_STATE pState, _In_reads_(cbData) PCBYTE pbSrc, _Out_writes_(cbData) PBYTE pbDst, _In_ SIZE_T cbData)
Definition: rc4.c:82

Referenced by RSAENH_CPDecrypt(), and RSAENH_CPEncrypt().

◆ export_private_key_impl()

BOOL export_private_key_impl ( const KEY_CONTEXT *  ctx,
BYTE *  dst,
DWORD *  pubexp 
)

Definition at line 493 of file implglue.c.

494{
495 BYTE *modulus, *primes[2], *exponents[2], *coefficient, *private_exp;
496 SIZE_T modulus_size, primes_sizes[2];
497 UINT64 pubexp64;
498
499 if (!ctx->rsa.key) return FALSE;
500
501 modulus_size = SymCryptRsakeySizeofModulus( ctx->rsa.key );
502
503 primes_sizes[0] = SymCryptRsakeySizeofPrime( ctx->rsa.key, 0 );
504 primes_sizes[1] = SymCryptRsakeySizeofPrime( ctx->rsa.key, 1 );
505
506 modulus = dst;
507 primes[0] = modulus + modulus_size;
508 primes[1] = modulus + modulus_size + primes_sizes[0];
509
510 if (SymCryptRsakeyGetValue( ctx->rsa.key, modulus, modulus_size, &pubexp64, 1, primes, primes_sizes, 2,
512 {
514 return FALSE;
515 }
516
517 exponents[0] = primes[1] + primes_sizes[1];
518 exponents[1] = exponents[0] + primes_sizes[0];
519 coefficient = exponents[1] + primes_sizes[1];
520 private_exp = coefficient + primes_sizes[0];
521
522 if (SymCryptRsakeyGetCrtValue( ctx->rsa.key, exponents, primes_sizes, 2, coefficient, primes_sizes[0],
524 {
526 return FALSE;
527 }
528
529 *pubexp = pubexp64;
530 return TRUE;
531}
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
BYTE private_exp[512/8]
Definition: bcrypt.c:2643
BYTE coefficient[512/16]
Definition: bcrypt.c:2642
UINT32 SYMCRYPT_CALL SymCryptRsakeySizeofPrime(_In_ PCSYMCRYPT_RSAKEY pkRsakey, UINT32 index)
Definition: rsakey.c:289
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptRsakeyGetValue(_In_ PCSYMCRYPT_RSAKEY pkRsakey, _Out_writes_bytes_(cbModulus) PBYTE pbModulus, SIZE_T cbModulus, _Out_writes_opt_(nPubExp) PUINT64 pu64PubExp, UINT32 nPubExp, _Out_writes_opt_(nPrimes) PBYTE *ppPrimes, _In_reads_opt_(nPrimes) SIZE_T *pcbPrimes, UINT32 nPrimes, SYMCRYPT_NUMBER_FORMAT numFormat, UINT32 flags)
Definition: rsakey.c:1445
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptRsakeyGetCrtValue(_In_ PCSYMCRYPT_RSAKEY pkRsakey, _Out_writes_opt_(nCrtExponents) PBYTE *ppCrtExponents, _In_reads_(nCrtExponents) SIZE_T *pcbCrtExponents, UINT32 nCrtExponents, _Out_writes_bytes_opt_(cbCrtCoefficient) PBYTE pbCrtCoefficient, SIZE_T cbCrtCoefficient, _Out_writes_bytes_opt_(cbPrivateExponent) PBYTE pbPrivateExponent, SIZE_T cbPrivateExponent, SYMCRYPT_NUMBER_FORMAT numFormat, UINT32 flags)
Definition: rsakey.c:1518
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by crypt_export_private_key(), and duplicate_key_impl().

◆ export_public_key_impl()

BOOL export_public_key_impl ( const KEY_CONTEXT *  ctx,
BYTE *  dst,
DWORD *  pubexp 
)

Definition at line 450 of file implglue.c.

451{
452 BYTE *modulus = dst;
453 SIZE_T modulus_size;
454 UINT64 pubexp64;
455
456 if (!ctx->rsa.key) return FALSE;
457
458 modulus_size = SymCryptRsakeySizeofModulus( ctx->rsa.key );
459
460 if (SymCryptRsakeyGetValue( ctx->rsa.key, modulus, modulus_size, &pubexp64, 1, NULL, NULL, 0,
462 {
464 return FALSE;
465 }
466 *pubexp = pubexp64;
467 return TRUE;
468}
#define NULL
Definition: types.h:112

Referenced by crypt_export_public_key(), and duplicate_key_impl().

◆ finalize_hash_impl()

static void finalize_hash_impl ( struct hash *  hash,
BYTE *  hash_value,
DWORD  hash_size 
)
inlinestatic

Definition at line 61 of file implglue.h.

62{
63 SymCryptHashResult( hash->desc, &hash->state, hash_value, hash_size );
64}
SYMCRYPT_HASH_STATE state
Definition: bcrypt_main.c:112
const SYMCRYPT_HASH * desc
Definition: bcrypt_main.c:111
VOID SYMCRYPT_CALL SymCryptHashResult(_In_ PCSYMCRYPT_HASH pHash, _Inout_updates_bytes_(pHash->stateSize) PVOID pState, _Out_writes_(SYMCRYPT_MIN(cbResult, pHash->resultSize)) PBYTE pbResult, SIZE_T cbResult)
Definition: hash.c:193

Referenced by finalize_hash(), and RSAENH_CPSetHashParam().

◆ free_key_impl()

BOOL free_key_impl ( ALG_ID  algid,
KEY_CONTEXT *  ctx 
)

Definition at line 129 of file implglue.c.

130{
131 switch (algid)
132 {
133 case CALG_RSA_KEYX:
134 case CALG_RSA_SIGN:
135 if (ctx->rsa.key)
136 {
137 SymCryptRsakeyFree( ctx->rsa.key );
138 ctx->rsa.key = NULL;
139 }
140 break;
141 default:
142 break;
143 }
144 return TRUE;
145}
VOID SYMCRYPT_CALL SymCryptRsakeyFree(_Out_ PSYMCRYPT_RSAKEY pkObj)
Definition: rsakey.c:42

Referenced by destroy_hash(), and destroy_key().

◆ hash_block_len_impl()

static DWORD hash_block_len_impl ( const struct hash *  hash)
inlinestatic

Definition at line 71 of file implglue.h.

72{
74}
SIZE_T SYMCRYPT_CALL SymCryptHashInputBlockSize(_In_ PCSYMCRYPT_HASH pHash)
Definition: hash.c:140

Referenced by RSAENH_CPSetHashParam().

◆ hash_len_impl()

static DWORD hash_len_impl ( const struct hash *  hash)
inlinestatic

Definition at line 66 of file implglue.h.

67{
69}
SIZE_T SYMCRYPT_CALL SymCryptHashResultSize(_In_ PCSYMCRYPT_HASH pHash)
Definition: hash.c:132

Referenced by init_hash(), and RSAENH_CPSetHashParam().

◆ import_private_key_impl()

BOOL import_private_key_impl ( ALG_ID  algid,
const BYTE *  src,
DWORD  keylen,
DWORD  pubexp,
KEY_CONTEXT *  ctx 
)

Definition at line 533 of file implglue.c.

534{
535 const BYTE *modulus = src, *primes[2];
536 SIZE_T primes_sizes[2];
537 UINT64 exp64 = pubexp;
538
539 ctx->rsa.flags = SYMCRYPT_FLAG_KEY_NO_FIPS;
542
543 if (!(ctx->rsa.key = alloc_rsa_key( keylen * 8, TRUE )))
544 {
546 return FALSE;
547 }
548
549 primes[0] = modulus + keylen;
550 primes[1] = primes[0] + keylen / 2;
551
552 primes_sizes[0] = keylen / 2;
553 primes_sizes[1] = keylen / 2;
554
555 if (SymCryptRsakeySetValue( modulus, keylen, &exp64, 1, primes, primes_sizes, 2,
556 SYMCRYPT_NUMBER_FORMAT_LSB_FIRST, ctx->rsa.flags, ctx->rsa.key ))
557 {
559 return FALSE;
560 }
561
562 return TRUE;
563}
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptRsakeySetValue(_In_reads_bytes_(cbModulus) PCBYTE pbModulus, SIZE_T cbModulus, _In_reads_(nPubExp) PCUINT64 pu64PubExp, UINT32 nPubExp, _In_reads_opt_(nPrimes) PCBYTE *ppPrimes, _In_reads_opt_(nPrimes) SIZE_T *pcbPrimes, UINT32 nPrimes, SYMCRYPT_NUMBER_FORMAT numFormat, UINT32 flags, _Inout_ PSYMCRYPT_RSAKEY pkRsakey)
Definition: rsakey.c:1399
#define SYMCRYPT_FLAG_RSAKEY_SIGN
Definition: symcrypt.h:7598
#define SYMCRYPT_FLAG_RSAKEY_ENCRYPT
Definition: symcrypt.h:7599
#define SYMCRYPT_FLAG_KEY_NO_FIPS
Definition: symcrypt.h:7579

Referenced by duplicate_key_impl(), and import_private_key().

◆ import_public_key_impl()

BOOL import_public_key_impl ( ALG_ID  algid,
const BYTE *  src,
DWORD  keylen,
DWORD  pubexp,
KEY_CONTEXT *  ctx 
)

Definition at line 470 of file implglue.c.

471{
472 const BYTE *modulus = src;
473 UINT64 exp64 = pubexp;
474
475 ctx->rsa.flags = SYMCRYPT_FLAG_KEY_NO_FIPS;
478
479 if (!(ctx->rsa.key = alloc_rsa_key( keylen * 8, FALSE )))
480 {
482 return FALSE;
483 }
485 ctx->rsa.flags, ctx->rsa.key ))
486 {
488 return FALSE;
489 }
490 return TRUE;
491}

Referenced by duplicate_key_impl(), and import_public_key().

◆ init_hash_impl()

BOOL init_hash_impl ( ALG_ID  algid,
struct hash *  hash 
)

Definition at line 63 of file implglue.c.

64{
65 const SYMCRYPT_HASH *algorithms[] =
66 {
74 };
75
76 memset( hash, 0, sizeof(*hash) );
77 if (GET_ALG_CLASS(algid) != ALG_CLASS_HASH) return TRUE;
78 if (GET_ALG_SID(algid) >= ARRAY_SIZE(algorithms)) return TRUE;
79 if (!(hash->desc = algorithms[GET_ALG_SID(algid)])) return TRUE;
81 return TRUE;
82}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define memset(x, y, z)
Definition: compat.h:39
const PCSYMCRYPT_HASH SymCryptSha256Algorithm
Definition: sha256.c:46
VOID SYMCRYPT_CALL SymCryptHashInit(_In_ PCSYMCRYPT_HASH pHash, _Out_writes_bytes_(pHash->stateSize) PVOID pState)
Definition: hash.c:173
const PCSYMCRYPT_HASH SymCryptSha1Algorithm
Definition: sha1.c:29
const PCSYMCRYPT_HASH SymCryptMd2Algorithm
Definition: md2.c:40
const PCSYMCRYPT_HASH SymCryptMd5Algorithm
Definition: md5.c:43
const PCSYMCRYPT_HASH SymCryptSha512Algorithm
Definition: sha512.c:170
const PCSYMCRYPT_HASH SymCryptSha384Algorithm
Definition: sha512.c:169
const PCSYMCRYPT_HASH SymCryptMd4Algorithm
Definition: md4.c:46
struct _SYMCRYPT_HASH SYMCRYPT_HASH
#define ALG_SID_MD4
Definition: wincrypt.h:2029
#define ALG_SID_MD2
Definition: wincrypt.h:2028
#define ALG_SID_SHA_512
Definition: wincrypt.h:2042
#define GET_ALG_SID(x)
Definition: wincrypt.h:1964
#define ALG_CLASS_HASH
Definition: wincrypt.h:1971
#define ALG_SID_SHA_384
Definition: wincrypt.h:2041
#define ALG_SID_MD5
Definition: wincrypt.h:2030
#define ALG_SID_SHA_256
Definition: wincrypt.h:2040
#define ALG_SID_SHA
Definition: wincrypt.h:2031
#define GET_ALG_CLASS(x)
Definition: wincrypt.h:1962

Referenced by finalize_hash(), init_hash(), and RSAENH_CPSetHashParam().

◆ new_key_impl()

BOOL new_key_impl ( ALG_ID  algid,
KEY_CONTEXT *  ctx,
DWORD  keylen 
)

Definition at line 95 of file implglue.c.

96{
97 switch (algid)
98 {
99 case CALG_RSA_KEYX:
100 case CALG_RSA_SIGN:
101 {
102 UINT64 pubexp = 65537;
103
104 ctx->rsa.flags = SYMCRYPT_FLAG_KEY_NO_FIPS;
106 else ctx->rsa.flags |= SYMCRYPT_FLAG_RSAKEY_SIGN;
107
108 if (!(ctx->rsa.key = alloc_rsa_key( keylen * 8, TRUE )))
109 {
111 return FALSE;
112 }
113 if (SymCryptRsakeyGenerate( ctx->rsa.key, &pubexp, 1, ctx->rsa.flags ))
114 {
115 SymCryptRsakeyFree( ctx->rsa.key );
116 ctx->rsa.key = NULL;
118 return FALSE;
119 }
120 break;
121 }
122 default:
124 return FALSE;
125 }
126 return TRUE;
127}
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptRsakeyGenerate(_Inout_ PSYMCRYPT_RSAKEY pkRsakey, _In_reads_opt_(nPubExp) PCUINT64 pu64PubExp, UINT32 nPubExp, _In_ UINT32 flags)
Definition: rsakey.c:514

Referenced by RSAENH_CPGenKey().

◆ setup_key_impl()

BOOL setup_key_impl ( ALG_ID  algid,
KEY_CONTEXT *  ctx,
DWORD  keylen,
DWORD  effective_keylen,
DWORD  saltlen,
const BYTE *  keyvalue 
)

Definition at line 147 of file implglue.c.

149{
150 switch (algid)
151 {
152 case CALG_RC4:
153 SymCryptRc4Init( &ctx->rc4, secret, keylen + saltlen );
154 break;
155 case CALG_RC2:
156 SymCryptRc2ExpandKeyEx( &ctx->rc2, secret, keylen + saltlen,
157 effective_keylen ? effective_keylen : keylen << 3 );
158 break;
159 case CALG_3DES:
160 SymCrypt3DesExpandKey( &ctx->des3, secret, 24 );
161 break;
162 case CALG_3DES_112:
163 SymCrypt3DesExpandKey( &ctx->des3, secret, 16 );
164 break;
165 case CALG_DES:
166 SymCryptDesExpandKey( &ctx->des, secret, 8 );
167 break;
168 case CALG_AES:
169 case CALG_AES_128:
170 SymCryptAesExpandKey( &ctx->aes, secret, 16 );
171 break;
172 case CALG_AES_192:
173 SymCryptAesExpandKey( &ctx->aes, secret, 24 );
174 break;
175 case CALG_AES_256:
176 SymCryptAesExpandKey( &ctx->aes, secret, 32 );
177 break;
178 }
179
180 return TRUE;
181}
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptDesExpandKey(_Out_ PSYMCRYPT_DES_EXPANDED_KEY pExpandedKey, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
Definition: 3des.c:124
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptAesExpandKey(_Out_ PSYMCRYPT_AES_EXPANDED_KEY pExpandedKey, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
Definition: aes-key.c:219
SYMCRYPT_ERROR SYMCRYPT_CALL SymCrypt3DesExpandKey(_Out_ PSYMCRYPT_3DES_EXPANDED_KEY pExpandedKey, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
Definition: 3des.c:295
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptRc4Init(_Out_ PSYMCRYPT_RC4_STATE pState, _In_reads_(cbKey) PCBYTE pbKey, _In_ SIZE_T cbKey)
Definition: rc4.c:15
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptRc2ExpandKeyEx(_Out_ PSYMCRYPT_RC2_EXPANDED_KEY pExpandedKey, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey, UINT32 effectiveKeySizeInBits)
Definition: rc2.c:129

Referenced by setup_key().

◆ sign_hash_impl()

BOOL sign_hash_impl ( KEY_CONTEXT *  ctx,
const BYTE *  in,
BYTE *  out 
)

Definition at line 426 of file implglue.c.

Referenced by RSAENH_CPSignHash().

◆ update_hash_impl()

static void update_hash_impl ( struct hash *  hash,
const BYTE *  data,
DWORD  len 
)
inlinestatic

Definition at line 56 of file implglue.h.

57{
59}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
VOID SYMCRYPT_CALL SymCryptHashAppend(_In_ PCSYMCRYPT_HASH pHash, _Inout_updates_bytes_(pHash->stateSize) PVOID pState, _In_reads_(cbData) PCBYTE pbData, SIZE_T cbData)
Definition: hash.c:182

Referenced by finalize_hash(), init_hash(), RSAENH_CPSetHashParam(), and update_hash().

◆ verify_signature_impl()

BOOL verify_signature_impl ( KEY_CONTEXT *  ctx,
const BYTE *  in,
BYTE *  out 
)

Definition at line 431 of file implglue.c.

Referenced by RSAENH_CPVerifySignature().