001 /*
002 * ===========================================================================================
003 * = COPYRIGHT
004 *          PAX Computer Technology (Shenzhen) Co., Ltd. PROPRIETARY INFORMATION
005 *   This software is supplied under the terms of a license agreement or nondisclosure
006 *   agreement with PAX Computer Technology (Shenzhen) Co., Ltd. and may not be copied or
007 *   disclosed except in accordance with the terms in that agreement.
008 *     Copyright (C) 2017-2023 PAX Computer Technology (Shenzhen) Co., Ltd. All rights reserved.
009 * Description: // Detail description about the function of this module,
010 *             // interfaces with the other modules, and dependencies.
011 * Revision History:
012 * Date                         Author                        Action
013 * 2017/04/01                   PAX                     Create/Add/Modify/Delete
014 * ===========================================================================================
015 */
016 
017package com.pax.dal.entity;
018
019/**
020 * <div class="zh"> DUKPT的MAC算法模式定义 </div> <div class="en"> DUKPT MAC Mode </div>
021 * 
022 * @author Steven.W
023 * 
024 */
025public enum EDUKPTMacMode {
026    /**
027     * <div class="zh"> 将BLOCK1用MAC密钥做TDES加密,加密结果与BLOCK2进行逐位异或后再用MAC密钥做TDES加密,依次进行得到8字节的加密结果。 KSN自动加1 </div> <div
028     * class="en"> Doing TDES encryption for BLOCK1 by using MAC key. Doing TDES encryption again by using MAC key when
029     * and after bitwise XOR the previous encryption result with BLOCK2. Processing in turn to get the 8 bytes
030     * encryption result.KSN auto-add 1 </div>
031     */
032    MODE_00((byte) 0),
033    /**
034     * <div class="zh"> 将BLOCK1和BLOCK2进行逐位异或,异或结果与BLOCK3进行逐位异或,依次进行,最后得到8字节的异或结果,将该结果用MAC密钥进行TDES加密运算。 KSN自动加1。 </div>
035     * <div class="en"> Doing bitwise XOR for BLOCK1 and BLOCK2; Do bitwise XOR again by using previous XOR result with
036     * BLOCK3. Do it in turn and finally get the 8 bytes XOR result. Using MAC key to process TDES encryption for the
037     * result.KSN auto-add 1 </div>
038     */
039    MODE_01((byte) 1),
040
041    /**
042     * <div class="zh">
043     * ANSIX9.19规范,将BLOCK1用MAC密钥做DES加密(只取前8个字节的key),加密结果与BLOCK2进行逐位异或后再用MAC密钥做DES加密,依次进行得到8字节的加密结果,直到最后一次采用TDES加密。
044     * KSN自动加1。 </div> <div class="en"> ANSIX9.19 standard, Do DES encryption for BLOCK1 by using MAC key (only take the
045     * first 8 bytes of key). The encryption result wills bitwise XOR with BLOCK2,and then doing DES encryption by using
046     * MAC key again. Do it in turn and get the 8 bytes encryption result. Using TDES to encrypt in the last time.KSN
047     * auto-add 1 </div>
048     */
049    MODE_02((byte) 2),
050
051    /**
052     * <div class="zh">
053     * hmac-sha256模式。将MAC密钥作为hmac 密钥。使用DUKPT_MAC_BOTH_KEY(request and response MAC密钥),KSN 自动加 1</div>
054     * <div class="en">hmac-sha256 mode. Use the MAC key as the hmac key. Using DUKPT_MAC_BOTH_KEY (request and response MAC key), KSN is automatically incremented by 1</div>
055     */
056    MODE_05((byte) 5),
057    /**
058     * <div class="zh"> 将BLOCK1用MAC密钥做TDES加密,加密结果与BLOCK2进行逐位异或后再用MAC密钥做TDES加密,依次进行得到8字节的加密结果。KSN不自动加1。 </div> <div
059     * class="en"> Doing TDES encryption for BLOCK1 by using MAC key. Doing TDES encryption again by using MAC key when
060     * and after bitwise XOR the previous encryption result with BLOCK2. Processing in turn to get the 8 bytes
061     * encryption result.KSN won't auto-add 1 </div>
062     */
063    MODE_20((byte) 20),
064    /**
065     * <div class="zh"> 将BLOCK1和BLOCK2进行逐位异或,异或结果与BLOCK3进行逐位异或,依次进行,最后得到8字节的异或结果,将该结果用MAC密钥进行TDES加密运算。KSN不自动加1。 </div>
066     * <div class="en"> Doing bitwise XOR for BLOCK1 and BLOCK2; Do bitwise XOR again by using previous XOR result with
067     * BLOCK3. Do it in turn and finally get the 8 bytes XOR result. Using MAC key to process TDES encryption for the
068     * result.KSN won't auto-add 1 </div>
069     */
070    MODE_21((byte) 21),
071    /**
072     * <div class="zh">
073     * ANSIX9.19 规范,将 BLOCK1 用 MAC 密钥做DES加密(只取前 8个字节的 key), 加密结果与
074     * BLOCK2 进行逐位异或后再用 MAC 密钥做 DES 加密,依次进行得到 8 字节的加密结果, 直到最后一次采用TDES
075     * 加密。 KSN 不自动加 1,其它值保留扩展 MAC 算法。 </div>
076     * <div class="en"> ANSIX9.19 specification, BLOCK1 use MAC key to do DES encryption (only take the first 8 bytes of the key), encryption results with
077     * BLOCK2 performs bit-by-bit XOR and then uses MAC key to do DES encryption, successively obtaining 8-byte encryption results until TDES is used for the last time
078     * Encryption. KSN does not automatically add 1, and other values are reserved for the extended MAC algorithm. </div>
079     */
080    MODE_22((byte) 22),
081
082    /**
083     * <div class="zh">
084     * hmac-sha256模式。将MAC密钥作为hmac 密钥。使用DUKPT_MAC_BOTH_KEY(request and response MAC密钥),KSN 不自动加1 </div>
085     * <div class="en"> hmac-sha256 mode. Use the MAC key as the hmac key. With DUKPT_MAC_BOTH_KEY (request and response MAC key), KSN is not automatically incremented by 1</div>
086     */
087    MODE_25((byte) 25),
088
089    /**
090     * <div class="zh"> 将BLOCK1用MAC密钥做TDES加密,加密结果与BLOCK2进行逐位异或后再用MAC密钥做TDES加密,依次进行得到8字节的加密结果。 KSN不自动加1。 </div> <div
091     * class="en"> Doing TDES encryption for BLOCK1 by using MAC key. Doing TDES encryption again by using MAC key when
092     * and after bitwise XOR the previous encryption result with BLOCK2. Processing in turn to get the 8 bytes
093     * encryption result.KSN won't auto-add 1 </div>
094     */
095    MODE_40((byte) 40),
096    /**
097     * <div class="zh"> 将BLOCK1和BLOCK2进行逐位异或,异或结果与BLOCK3进行逐位异或,依次进行,最后得到8字节的异或结果,将该结果用MAC密钥进行TDES加密运算。 KSN不自动加1。 </div>
098     * <div class="en"> Doing bitwise XOR for BLOCK1 and BLOCK2; Do bitwise XOR again by using previous XOR result with
099     * BLOCK3. Do it in turn and finally get the 8 bytes XOR result. Using MAC key to process TDES encryption for the
100     * result.KSN won't auto-add 1 </div>
101     */
102    MODE_41((byte) 41),
103    /**
104     * <div class="zh">
105     * ANSIX9.19 规范,将 BLOCK1 用 MAC 密钥做DES加密(只取前 8个字节的 key),加密结果与
106     * BLOCK2 进行逐位异或后再用 TAK 做 DES 加密,依次进行得到 8 字节的加密结果,直到最后一次采用
107     * TDES加密。 KSN 不自动加 1 ,其它值保留扩展 MAC 算法。 </div>
108     * <div class="en"> ANSIX9.19 specification, BLOCK1 use MAC key to do DES encryption (only take the first 8 bytes of the key), encryption results with
109     * BLOCK2 performs bit-by-bit XOR and then uses TAK to do DES encryption, successively obtaining 8-byte encryption results until the last use
110     * TDES encryption. KSN does not automatically add 1, and other values are reserved for the extended MAC algorithm. </div>
111     */
112    MODE_42((byte) 42),
113
114    /**
115     * <div class="zh">
116     *  hmac-sha256模式。将MAC密钥作为hmac 密钥。使用DUKPT_MAC_RSP_KEY(response MAC密钥),KSN 不自动加1 </div>
117     *  <div class="en"> hmac-sha256 mode. Use the MAC key as the hmac key. If DUKPT_MAC_RSP_KEY (response MAC key) is used, KSN is not automatically incremented by 1</div>
118     */
119    MODE_45((byte) 45);
120
121    private byte dukptMacMode;
122
123    private EDUKPTMacMode(byte dukptMacMode) {
124        this.dukptMacMode = dukptMacMode;
125    }
126
127    public byte getDUKPTMacMode() {
128        return dukptMacMode;
129    }
130}