ReactOS 0.4.17-dev-1005-g171e1de
desx.c File Reference
#include "precomp.h"
Include dependency graph for desx.c:

Go to the source code of this file.

Functions

SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptDesxExpandKey (_Out_ PSYMCRYPT_DESX_EXPANDED_KEY pExpandedKey, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
 
VOID SYMCRYPT_CALL SymCryptDesxEncrypt (_In_ PCSYMCRYPT_DESX_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_DESX_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_DESX_BLOCK_SIZE) PBYTE pbDst)
 
VOID SYMCRYPT_CALL SymCryptDesxDecrypt (_In_ PCSYMCRYPT_DESX_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_DESX_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_DESX_BLOCK_SIZE) PBYTE pbDst)
 
VOID SYMCRYPT_CALL SymCryptDesxSelftest (void)
 

Variables

const SYMCRYPT_BLOCKCIPHER SymCryptDesxBlockCipher_default
 
const PCSYMCRYPT_BLOCKCIPHER SymCryptDesxBlockCipher = &SymCryptDesxBlockCipher_default
 
static const BYTE desxKnownKey [24]
 
static const BYTE desxKnownPlaintext []
 
static const BYTE desxKnownCiphertext []
 

Function Documentation

◆ SymCryptDesxDecrypt()

Definition at line 68 of file desx.c.

72{
74
75 //
76 // We buffer the result locally to obey the read once/write once rule.
77 //
78 SymCryptXorBytes( pbSrc, pExpandedKey->outputWhitening, buf, 8 );
80 SymCryptXorBytes( buf, pExpandedKey->inputWhitening, pbDst, 8 );
81
82 SymCryptWipeKnownSize( buf, sizeof( buf ) );
83}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
FORCEINLINE VOID SYMCRYPT_CALL SymCryptWipeKnownSize(_Out_writes_bytes_(cbData) PVOID pbData, SIZE_T cbData)
VOID SYMCRYPT_CALL SymCryptXorBytes(_In_reads_(cbBytes) PCBYTE pbSrc1, _In_reads_(cbBytes) PCBYTE pbSrc2, _Out_writes_(cbBytes) PBYTE pbResult, SIZE_T cbBytes)
Definition: libmain.c:236
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
#define SYMCRYPT_ALIGN
PCBYTE pbSrc
PCBYTE PBYTE pbDst
PCVOID pExpandedKey
unsigned char BYTE
Definition: xxhash.c:193

Referenced by SymCryptDesxSelftest().

◆ SymCryptDesxEncrypt()

Definition at line 49 of file desx.c.

53{
55
56 //
57 // We buffer the result locally to obey the read once/write once rule.
58 //
59 SymCryptXorBytes( pbSrc, pExpandedKey->inputWhitening, buf, 8 );
61 SymCryptXorBytes( buf, pExpandedKey->outputWhitening, pbDst, 8 );
62
63 SymCryptWipeKnownSize( buf, sizeof( buf ) );
64}
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

Referenced by SymCryptDesxSelftest().

◆ SymCryptDesxExpandKey()

SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptDesxExpandKey ( _Out_ PSYMCRYPT_DESX_EXPANDED_KEY  pExpandedKey,
_In_reads_(cbKey) PCBYTE  pbKey,
SIZE_T  cbKey 
)

Definition at line 31 of file desx.c.

34{
35 if( cbKey != 24 )
36 {
37 return SYMCRYPT_WRONG_KEY_SIZE;
38 }
39
41 memcpy( pExpandedKey->inputWhitening, pbKey+8, 8 );
42 memcpy( pExpandedKey->outputWhitening, pbKey+16, 8 );
43
44 return SYMCRYPT_NO_ERROR;
45}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptDesExpandKey(_Out_ PSYMCRYPT_DES_EXPANDED_KEY pExpandedKey, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
Definition: 3des.c:124
PCBYTE pbKey
PCBYTE SIZE_T cbKey

Referenced by SymCryptDesxSelftest().

◆ SymCryptDesxSelftest()

VOID SYMCRYPT_CALL SymCryptDesxSelftest ( void  )

Definition at line 103 of file desx.c.

104{
107
108 if( SymCryptDesxExpandKey( &key, desxKnownKey, sizeof( desxKnownKey )) != SYMCRYPT_NO_ERROR )
109 {
110 SymCryptFatal( 'desx' );
111 }
112
114
116
118 {
119 SymCryptFatal( 'desy' );
120 }
121
123
125
127 {
128 SymCryptFatal( 'desz' );
129 }
130
131}
VOID SYMCRYPT_CALL SymCryptDesxEncrypt(_In_ PCSYMCRYPT_DESX_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_DESX_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_DESX_BLOCK_SIZE) PBYTE pbDst)
Definition: desx.c:49
static const BYTE desxKnownPlaintext[]
Definition: desx.c:92
SYMCRYPT_ERROR SYMCRYPT_CALL SymCryptDesxExpandKey(_Out_ PSYMCRYPT_DESX_EXPANDED_KEY pExpandedKey, _In_reads_(cbKey) PCBYTE pbKey, SIZE_T cbKey)
Definition: desx.c:31
static const BYTE desxKnownCiphertext[]
Definition: desx.c:96
VOID SYMCRYPT_CALL SymCryptDesxDecrypt(_In_ PCSYMCRYPT_DESX_EXPANDED_KEY pExpandedKey, _In_reads_(SYMCRYPT_DESX_BLOCK_SIZE) PCBYTE pbSrc, _Out_writes_(SYMCRYPT_DESX_BLOCK_SIZE) PBYTE pbDst)
Definition: desx.c:68
static const BYTE desxKnownKey[24]
Definition: desx.c:86
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
VOID SYMCRYPT_CALL SymCryptInjectError(PBYTE pbData, SIZE_T cbData)
Definition: copy.c:22
_Analysis_noreturn_ VOID SYMCRYPT_CALL SymCryptFatal(UINT32 fatalCode)
#define SYMCRYPT_DESX_BLOCK_SIZE
Definition: symcrypt.h:4500
SYMCRYPT_DESX_EXPANDED_KEY

Variable Documentation

◆ desxKnownCiphertext

const BYTE desxKnownCiphertext[]
static
Initial value:
= {
0x66, 0x77, 0x1f, 0x2a, 0x0c, 0x05, 0x01, 0xca
}

Definition at line 96 of file desx.c.

Referenced by SymCryptDesxSelftest().

◆ desxKnownKey

const BYTE desxKnownKey[24]
static
Initial value:
= {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
0x01, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18
}

Definition at line 86 of file desx.c.

Referenced by SymCryptDesxSelftest().

◆ desxKnownPlaintext

const BYTE desxKnownPlaintext[]
static
Initial value:
= {
0xd9, 0xb6, 0xa1, 0x4e, 0xe6, 0x71, 0x4e, 0x17
}

Definition at line 92 of file desx.c.

Referenced by SymCryptDesxSelftest().

◆ SymCryptDesxBlockCipher

Definition at line 27 of file desx.c.

◆ SymCryptDesxBlockCipher_default

const SYMCRYPT_BLOCKCIPHER SymCryptDesxBlockCipher_default
Initial value:

Definition at line 11 of file desx.c.