! *************************************************************************
! *                                                                       *
! * HP CONFIDENTIAL. This software is confidential proprietary software   *
! * licensed by Hewlett-Packard Development Company, L.P., and is not     *
! * authorized to be used, duplicated OR disclosed to anyone without the  *
! * prior written permission of HP.                                       *
! * © 2021 Copyright Hewlett-Packard Development Company, L.P.            *
! *                                                                       *
! * VMS SOFTWARE, INC. CONFIDENTIAL. This software is confidential        *
! * proprietary software licensed by VMS Software, Inc., and is not       *
! * authorized to be used, duplicated or disclosed to anyone without      *
! * the prior written permission of VMS Software, Inc.                    *
! * © 2021 Copyright VMS Software, Inc.                                   *
! *                                                                       *
! *************************************************************************
! ********************************************************************************************************************************
!  Created:  9-Mar-2021 22:27:19 by OpenVMS SDL EV3-3      
!  Source:  21-SEP-2005 15:44:14 $1$DGA8085:[ENCRYPT.SRC]ENCRYPT_STRUCTURES.SDL;/ 
! ********************************************************************************************************************************
 
!*** MODULE $ENCSTRDEF ***
!  Definitions for Encryption structures
!       KEY_SYSTEM              system 
!       KEY_GROUP               group 
!       KEY_PROCESS             process 
!       KEY_JOB                 job
!       KEY_LITERAL             literal key definition, don't compress
! 	KEY_AES			AES Key encryption/decryption
literal ENCRYPT$M_KEY_SYSTEM = %X'1';
literal ENCRYPT$M_KEY_GROUP = %X'2';
literal ENCRYPT$M_KEY_PROCESS = %X'4';
literal ENCRYPT$M_KEY_JOB = %X'8';
literal ENCRYPT$m_avail1 = %X'10';
literal ENCRYPT$M_KEY_LITERAL = %X'20';
literal ENCRYPT$M_KEY_AES = %X'40';
literal ENCRYPT$S_KEY_BITS = 1;
macro ENCRYPT$V_KEY_SYSTEM = 0,0,1,0 %;
macro ENCRYPT$V_KEY_GROUP = 0,1,1,0 %;
macro ENCRYPT$V_KEY_PROCESS = 0,2,1,0 %;
macro ENCRYPT$V_KEY_JOB = 0,3,1,0 %;
macro ENCRYPT$v_avail1 = 0,4,1,0 %;
macro ENCRYPT$V_KEY_LITERAL = 0,5,1,0 %;
macro ENCRYPT$V_KEY_AES = 0,6,1,0 %;
literal ENCRYPT$M_VALID_KEY_BITS = 111;
!       KEY$SYSTEM              system
!       KEY$GROUP               group
!       KEY$PROCESS             process
!       KEY$JOB                 job
!       avail1                  unused
!       KEY$LITERAL             literal key definition, don't compress
!       KEY$AES			AES Key encryption/decryption
literal ENCRYPT$K_KEY$SYSTEM = 0;
literal ENCRYPT$K_KEY$GROUP = 1;
literal ENCRYPT$K_KEY$PROCESS = 2;
literal ENCRYPT$K_KEY$JOB = 3;
literal ENCRYPT$k_avail1 = 4;
literal ENCRYPT$K_KEY$LITERAL = 5;
literal ENCRYPT$K_KEY$AES = 6;
!       FILE_ENCRYPT            encrypt/decrypt direction
!       FILE_DELETE             delete source file after operation
!       FILE_ERASE              erase source file when deleting
!       FILE_LOG                log file operation
!       FILE_UNUSED             -unused
!       FILE_STATISTICS         log statistics too
!       FILE_COMPRESS           compress input
!       FILE_EXTLOG             extended log
!       FILE_IGNORE_CRC         Ignore CRC generation/checking
!       FILE_V011               Generate V1.1-compatible ciphertext file
!       FILE_KEY_VALUE          Pass a key by value
! 	FILE_AES		AES File Operation
literal ENCRYPT$M_FILE_ENCRYPT = %X'1';
literal ENCRYPT$M_FILE_DELETE = %X'2';
literal ENCRYPT$M_FILE_ERASE = %X'4';
literal ENCRYPT$M_FILE_LOG = %X'8';
literal ENCRYPT$M_FILE_UNUSED = %X'10';
literal ENCRYPT$M_FILE_STATISTICS = %X'20';
literal ENCRYPT$M_FILE_COMPRESS = %X'40';
literal ENCRYPT$M_FILE_EXTLOG = %X'80';
literal ENCRYPT$M_FILE_IGNORE_CRC = %X'100';
literal ENCRYPT$M_FILE_V011 = %X'200';
literal ENCRYPT$M_FILE_KEY_VALUE = %X'400';
literal ENCRYPT$M_FILE_AES = %X'800';
literal ENCRYPT$S_FILE_OPS = 2;
macro ENCRYPT$V_FILE_ENCRYPT = 0,0,1,0 %;
macro ENCRYPT$V_FILE_DELETE = 0,1,1,0 %;
macro ENCRYPT$V_FILE_ERASE = 0,2,1,0 %;
macro ENCRYPT$V_FILE_LOG = 0,3,1,0 %;
macro ENCRYPT$V_FILE_STATISTICS = 0,5,1,0 %;
macro ENCRYPT$V_FILE_COMPRESS = 0,6,1,0 %;
macro ENCRYPT$V_FILE_EXTLOG = 0,7,1,0 %;
macro ENCRYPT$V_FILE_IGNORE_CRC = 0,8,1,0 %;
macro ENCRYPT$V_FILE_V011 = 0,9,1,0 %;
macro ENCRYPT$V_FILE_KEY_VALUE = 0,10,1,0 %;
macro ENCRYPT$V_FILE_AES = 0,11,1,0 %;
literal ENCRYPT$M_VALID_FILE_BITS = 4079;
!       KEY_LENGTH                      /* original key string length
!       KEYF_IS_COMPRESSED              /* key is compressed text
!       KEYF_LITERAL                    /* key is literal value
!       KEYF_TOBE_COMPRESSED            /* compression was deferred
!       KEYF_AES                        /* Key is AES encrypted
!       KEYF_UNUSED                     /* unused
literal encrypt$m_keyf_is_compressed = %X'1';
literal encrypt$m_keyf_literal = %X'2';
literal encrypt$m_keyf_tobe_compressed = %X'4';
literal encrypt$m_keyf_aes = %X'8';
literal encrypt$S_stored_key_flags = 4;
macro encrypt$w_key_length = 0,0,16,0 %;
macro encrypt$r_key_flags_u = 2,0,16,0 %;
literal encrypt$s_key_flags_u = 2;
macro encrypt$r_key_flags_w = 2,0,16,0 %;
literal encrypt$s_key_flags_w = 2;
macro encrypt$w_key_flags = 2,0,16,0 %;
macro encrypt$r_key_flags_b = 2,0,16,0 %;
literal encrypt$s_key_flags_b = 2;
macro encrypt$v_keyf_is_compressed = 2,0,1,0 %;
macro encrypt$v_keyf_literal = 2,1,1,0 %;
macro encrypt$v_keyf_tobe_compressed = 2,2,1,0 %;
macro encrypt$v_keyf_aes = 2,3,1,0 %;
literal ENCRYPT$M_VALID_DES_KEY_FLAGS = 7;
literal ENCRYPT$M_VALID_AES_KEY_FLAGS = 15;
! 
!  Programmable interface itemlist item codes
!       
!       Algorithm specific optional parameters. For example with the
!       DES based algorithms, <optparm_one> is defined as the address
!       of an 8-byte initialization vector (IV) to be used instead of
!       any residual IV remaining from a previous operation.
!       The interpretation of these parameters is documented with
!       the specific algorithms.
!         optparam_one          Optional Parameter
!         optparam_two          Optional Parameter
!         optparam_three        Optional Parameter
!         optparam_four         Optional Parameter
!         optparam_five         Optional Parameter
!         optparam_six          Optional Parameter
!         optparam_seven        Optional Parameter
!         optparam_eight        Optional Parameter
! 
!       References the actual key value to be used. Overrides
!       any key name/value reference supplied in other call
!       parameters
!         key_name              A key namestring
!         key_value             A key value
!         key_flags             Key interpretation flags
!       
!       Algorithm name specification
!         algorithm_spec        algorithm name or type specification
!         algorithm_type        algorithm specification type code
! 
!       for encrypt$encrypt_file() parameters
!         data_algorithm        inner algorithm name specification
!         qual_context          common qualifier context
! 
!       max                     maximum itemlist number
literal encrypt$k_optparam_one = 1;
literal encrypt$k_optparam_two = 2;
literal encrypt$k_optparam_three = 3;
literal encrypt$k_optparam_four = 4;
literal encrypt$k_optparam_five = 5;
literal encrypt$k_optparam_six = 6;
literal encrypt$k_optparam_seven = 7;
literal encrypt$k_optparam_eight = 8;
literal encrypt$k_key_name = 9;
literal encrypt$k_key_value = 10;
literal encrypt$k_key_flags = 11;
literal encrypt$k_algorithm_spec = 12;
literal encrypt$k_algorithm_type = 13;
literal encrypt$k_data_algorithm = 14;
literal encrypt$k_qual_context = 15;
literal encrypt$k_max = 16;
! 
!  Key name/value switch
! 
literal encrypt$k_name_specified = 0;
literal encrypt$k_value_specified = 1;
! 
!  Define structure for file encryption generated key vector
! 
!       FIL_BUFLEN              length of this record
!       FIL_FILEVER             file encrypt routine version
!       FIL_FILEUPD             decimal version
!       ---> FIL_KEY and FIL_IV are assumed to be contiguous
!       FIL_KEY                 data key value
!       FIL_IV                  initialize vector value
!       ---> FIL_KEY and FIL_IV are assumed to be contiguous
!       FIL_ALGCODE             file data encryption algorithm code
!       FIL_FLAGS               file encryption flags
!       FIL_COMPRESSED          file was compressed before enc
!       FIL_LONGCHECKSUM        longidudinal checksum present
!       FIL_ATR_LEN             size of attribute record
!       FIL_COMPRESS_MAX        blocks in compress buffer
!       FIL_ENCRYPT_MAX         blocks in encrypt buffer
!       FIL_DCXMAP_LEN          size of DCX map record if present
!       FIL_ALGNAM_LEN          size of data encryption algorithm
!       FIL_ALGNAM_STR          data encryption alg name
!       /* this is a varying length string with the next allocated field
!       /* starting 'algnam_len' bytes after 'algnam_str'
!       FIL_XKEY                extended key (counted string)
!       FIL_XIV                 extended IV (counted)
! 	FIL_XALGNAM_LEN         extended size of data encryption algorithm - AES
!       FIL_XALGNAM_STR         extended ALG name string - for AES
!       FIL_FILLER              filler to pad to 256 bytes
!       FIL_CHECKSUM            structure checksum
literal ENCRYPT$M_FIL_COMPRESSED = %X'1';
literal ENCRYPT$M_FIL_LONGCHECKSUM = %X'2';
literal ENCRYPT$S_FIL_RECORD = 256;
macro ENCRYPT$W_FIL_BUFLEN = 0,0,16,0 %;
macro ENCRYPT$B_FIL_FILEVER = 2,0,8,0 %;
macro ENCRYPT$B_FIL_FILEUPD = 3,0,8,0 %;
macro ENCRYPT$Q_FIL_KEY = 4,0,0,0 %;
literal ENCRYPT$S_FIL_KEY = 8;
macro ENCRYPT$Q_FIL_IV = 12,0,0,0 %;
literal ENCRYPT$S_FIL_IV = 8;
macro ENCRYPT$L_FIL_ALGCODE = 20,0,32,0 %;
macro ENCRYPT$L_FIL_FLAGS = 24,0,32,0 %;
macro ENCRYPT$V_FIL_COMPRESSED = 24,0,1,0 %;
macro ENCRYPT$V_FIL_LONGCHECKSUM = 24,1,1,0 %;
macro ENCRYPT$W_FIL_ATR_LEN = 28,0,16,0 %;
macro ENCRYPT$W_FIL_COMPRESS_MAX = 30,0,16,0 %;
macro ENCRYPT$W_FIL_ENCRYPT_MAX = 32,0,16,0 %;
macro ENCRYPT$R_FIL_DCXLEN_OVERLAY = 34,0,32,0 %;
macro ENCRYPT$L_FIL_DCXMAP_LEN = 34,0,32,0 %;
macro ENCRYPT$R_FIL_DCXMAP_LEN_WORD = 34,0,32,0 %;
literal ENCRYPT$S_FIL_DCXMAP_LEN_WORD = 4;
macro ENCRYPT$W_FIL_DCXMAP_LEN_LOW = 34,0,16,0 %;
macro ENCRYPT$W_FIL_DCXMAP_LEN_HIGH = 36,0,16,0 %;
macro ENCRYPT$W_FIL_ALGNAM_LEN = 38,0,16,0 %;
macro ENCRYPT$T_FIL_ALGNAM_STR = 40,0,0,0 %;
literal ENCRYPT$S_FIL_ALGNAM_STR = 6;
macro ENCRYPT$B_FIL_XKEY = 46,0,0,0 %;
literal ENCRYPT$S_FIL_XKEY = 80;
macro ENCRYPT$B_FIL_XIV = 126,0,0,0 %;
literal ENCRYPT$S_FIL_XIV = 80;
macro ENCRYPT$W_FIL_XALGNAM_LEN = 206,0,16,0 %;
macro ENCRYPT$T_FIL_XALGNAM_STR = 208,0,0,0 %;
literal ENCRYPT$S_FIL_XALGNAM_STR = 16;
macro ENCRYPT$B_FIL_FILLER = 224,0,0,1 %;
literal ENCRYPT$S_FIL_FILLER = 28;
macro ENCRYPT$L_FIL_CHECKSUM = 252,0,32,0 %;
! 
!  Attribute record structure in encrypted data file. The encrypted file
!  attributes are obtained from the input file fab and a chain of xab
!  blocks. The fab attributes are copied into a smaller structure, FABATR,
!  declared below and the xab attributes are copied in toto. 
! 
!       FILATR_LENGTH           length of file attributes
!       FILATR_FILL_60          unused
!       FILATR                  mask of whats present in attrib record
!       FABATR                  fabatr present
!       XABALL                  xaball present
!       XABDAT                  xabdat present
!       XABFHC                  xabfhc present
!       XABPRO                  xabpro present
!       PROACL                  xabpro access control list present
!       XABSUM                  xabsum present
!       UNASSIGNED              unassigned bits
!       ATR_FILLER              filler to pad to 256 bytes
literal ENCRYPT$M_FABATR = %X'1';
literal ENCRYPT$M_XABALL = %X'2';
literal ENCRYPT$M_XABDAT = %X'4';
literal ENCRYPT$M_XABFHC = %X'8';
literal ENCRYPT$M_XABPRO = %X'10';
literal ENCRYPT$M_PROACL = %X'20';
literal ENCRYPT$M_XABSUM = %X'40';
literal ENCRYPT$M_UNASSIGNED = %X'FFFFFF80';
literal ENCRYPT$S_ATR_RECORD = 256;
macro ENCRYPT$W_FILATR_LENGTH = 0,0,16,0 %;
macro ENCRYPT$R_FILATR_OVERLAY = 4,0,32,0 %;
macro ENCRYPT$L_FILATR = 4,0,32,0 %;
macro ENCRYPT$R_FILATR_BITS = 4,0,32,0 %;
macro ENCRYPT$V_FABATR = 4,0,1,0 %;
macro ENCRYPT$V_XABALL = 4,1,1,0 %;
macro ENCRYPT$V_XABDAT = 4,2,1,0 %;
macro ENCRYPT$V_XABFHC = 4,3,1,0 %;
macro ENCRYPT$V_XABPRO = 4,4,1,0 %;
macro ENCRYPT$V_PROACL = 4,5,1,0 %;
macro ENCRYPT$V_XABSUM = 4,6,1,0 %;
macro ENCRYPT$V_UNASSIGNED = 4,7,25,0 %;
literal ENCRYPT$S_UNASSIGNED = 25;
macro ENCRYPT$B_ATR_FILLER = 8,0,0,1 %;
literal ENCRYPT$S_ATR_FILLER = 248;
! 
!  While other attributes are stored as whole xabs, attributes from the
!  fab are copied to the xab-like structure FAB_ATTRIBUTES.
! 
!       COD             structure code
!       BLN             structure length
!       fill_50         spare
!       fill_51         address of next structure
!       ORG             file organization
!       RFM             record format
!       RAT             record attributes
!       FSZ             vfc header size
!       BKS             bucket size
!       RTV             retrieval pointer count
!       fill_52         spare
!       MRS             maximum record size
!       GBC             global buffer count
!       MRN             maximum record number
!       FOP             file operations
literal FABATR$S_FAB_ATTRIBUTES = 28;
macro FABATR$B_BLN = 1,0,8,0 %;
macro FABATR$B_ORG = 8,0,8,0 %;
macro FABATR$B_RFM = 9,0,8,0 %;
macro FABATR$B_RAT = 10,0,8,0 %;
macro FABATR$B_FSZ = 11,0,8,0 %;
macro FABATR$B_BKS = 12,0,8,0 %;
macro FABATR$B_RTV = 13,0,8,0 %;
macro FABATR$W_MRS = 16,0,16,0 %;
macro FABATR$W_GBC = 18,0,16,0 %;
macro FABATR$L_MRN = 20,0,32,0 %;
macro FABATR$L_FOP = 24,0,32,0 %;
!       EXCESS_DATA             Holds data beyond plaintext EOF
!       EXCESS_CRC              CRC of file
literal ENCRYPT$S_EXCESS_DATA = 34;
macro ENCRYPT$W_EXCESS_CRC = 0,0,16,0 %;
! 
!  Feature block
! 
literal ENCRYPT$M_PRODUCT_VERSION_MIN = %X'FF';
literal ENCRYPT$M_PRODUCT_VERSION_MAJ = %X'FF00';
literal ENCRYPT$S_FEATURE = 8;
macro ENCRYPT$L_FEATURE_CODE = 0,0,32,0 %;
macro ENCRYPT$R_VERSION_OVERLAY = 4,0,16,0 %;
macro ENCRYPT$W_PRODUCT_VERSION = 4,0,16,0 %;
macro ENCRYPT$R_PV_BITS = 4,0,16,0 %;
macro ENCRYPT$V_PRODUCT_VERSION_MIN = 4,0,8,0 %;
literal ENCRYPT$S_PRODUCT_VERSION_MIN = 8;
macro ENCRYPT$V_PRODUCT_VERSION_MAJ = 4,8,8,0 %;
literal ENCRYPT$S_PRODUCT_VERSION_MAJ = 8;
macro ENCRYPT$W_FEATURE_LENGTH = 6,0,16,0 %;
macro ENCRYPT$T_FEATURE_VALUE = 8,0,0,0 %;
literal ENCRYPT$M_FTR_REQUIRED = %X'1';
literal ENCRYPT$M_FTR_COMMENT = %X'2';
literal ENCRYPT$M_FTR_DEBUG = %X'4';
literal ENCRYPT$M_FTR_SILENT = %X'8';
literal ENCRYPT$S_FEATURE_CODE_BITS = 4;
macro ENCRYPT$V_FTR_REQUIRED = 0,0,1,0 %;
macro ENCRYPT$V_FTR_COMMENT = 0,1,1,0 %;
macro ENCRYPT$V_FTR_DEBUG = 0,2,1,0 %;
macro ENCRYPT$V_FTR_SILENT = 0,3,1,0 %;
macro ENCRYPT$V_FTR_NUMBER = 0,4,12,0 %;
literal ENCRYPT$S_FTR_NUMBER = 12;
! 
!  CRC checking feature block value definitions
! 
literal ENCRYPT$K_FEATURE_CRC = 33;
! 
!  Semantic tag feature block value definitions
! 
literal ENCRYPT$K_FEATURE_SEMTAG = 17;
literal ENCRYPT$S_FEATURE_SEMTAG_ = 66;
macro ENCRYPT$W_SEMTAG_LENGTH = 0,0,16,0 %;
macro ENCRYPT$T_SEMTAG_VALUE = 2,0,0,0 %;
literal ENCRYPT$S_SEMTAG_VALUE = 64;
literal ENCRYPT$K_FEATURES_MAX_LEN = 86;
! 
!  Define the encrypted file structure version of the current implementation
! 
!  Bumped FILE_VERSION for Encrypt-AES from 3 to 4
! 
literal ENCRYPT$K_FILE_VERSION = 4;
! 
!  Statistics record returned by encrypt$statistics()
! 
literal ENCRYPT$S_STAT_RECORD = 28;
! 
!  Format returned for statistics type code = 1
! 
!       STAT_TOTAL_RECORDS      statistics: total records 
!       STAT_TOTAL_BYTES        statistics: total bytes through stream
!       STAT_TOTAL_TIME         statistics: total time in facility
!       STAT_FILL_10            statistics: expansion
macro ENCRYPT$L_STAT_TOTAL_RECORDS = 0,0,32,0 %;
macro ENCRYPT$Q_STAT_TOTAL_BYTES = 4,0,0,0 %;
literal ENCRYPT$S_STAT_TOTAL_BYTES = 8;
macro ENCRYPT$Q_STAT_TOTAL_TIME = 12,0,0,0 %;
literal ENCRYPT$S_STAT_TOTAL_TIME = 8;
