1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Component                                                        */
16 /**                                                                       */
17 /**   DES Encryption Standard (DES)                                       */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    nx_des.h                                            PORTABLE C      */
28 /*                                                           6.1          */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Yuxin Zhou, Microsoft Corporation                                   */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the NetX DES encryption algorithm, derived        */
36 /*    principally from FIPS-46. From an 8 bytes of raw input, the DES     */
37 /*    encryption routine produces an 8-byte encryption of the input.      */
38 /*    Conversely, from an 8-byte encryption, the decryption routine       */
39 /*    produces the original 8 bytes of input. Note that the caller must   */
40 /*    ensure 8 bytes of input and output are provided.                    */
41 /*                                                                        */
42 /*    It is assumed that nx_api.h and nx_port.h have already been         */
43 /*    included.                                                           */
44 /*                                                                        */
45 /*  RELEASE HISTORY                                                       */
46 /*                                                                        */
47 /*    DATE              NAME                      DESCRIPTION             */
48 /*                                                                        */
49 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
50 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
51 /*                                            resulting in version 6.1    */
52 /*                                                                        */
53 /**************************************************************************/
54 
55 #ifndef  NX_DES_H
56 #define  NX_DES_H
57 
58 /* Define the DES context structure.  */
59 
60 typedef struct NX_DES_STRUCT
61 {
62 
63     ULONG       nx_des_encryption_keys[32];             /* Contains the encryption keys     */
64     ULONG       nx_des_decryption_keys[32];             /* Contains the decryption keys     */
65 } NX_DES;
66 
67 
68 /* Define the function prototypes for DES.  */
69 
70 UINT        _nx_des_key_set(NX_DES *context, UCHAR key[8]);
71 UINT        _nx_des_encrypt(NX_DES *context, UCHAR source[8], UCHAR destination[8]);
72 UINT        _nx_des_decrypt(NX_DES *context, UCHAR source[8], UCHAR destination[8]);
73 VOID        _nx_des_process_block(UCHAR source[8], UCHAR destination[8], ULONG keys[32]);
74 
75 #endif
76 
77