123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ShengJu_CUT100_DES.MessageEntity.Outgoing
- {
- /// <summary>
- /// 对进行高级格式化后自动创建的默认应用目录下的4个文件,按指定编号的密钥验证旧密钥后将旧密钥的更改为新密钥
- /// </summary>
- public class ModifyPredefinedFileKey : MessageBase
- {
- public enum PredefinedFileKeyTypeEnum
- {
- 根密钥 = 0x00,
- 文件1读密钥 = 0x01,
- 文件1读写密钥 = 0x02,
- 文件2读密钥 = 0x03,
- 文件2读写密钥 = 0x04,
- 文件3读密钥 = 0x05,
- 文件3读写密钥 = 0x06,
- 文件4读密钥 = 0x07,
- 文件4读写密钥 = 0x08
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="fileId">1-4</param>
- /// <param name="blockAddress">0-3</param>
- /// <param name="readKey">16 bytes key,密钥值需要与制定文件的读写密钥相对应</param>
- public ModifyPredefinedFileKey(PredefinedFileKeyTypeEnum keyType, byte[] oldKey, byte[] newKey)
- {
- if (oldKey == null || newKey == null)
- throw new ArgumentNullException("must provide oldKey and newKey");
- if (oldKey.Length != 16 || newKey.Length != 16)
- throw new ArgumentException("oldKey and newKey must has its length to 16");
- base.命令代码 = CommandType.DesFireEV1操作命令_更改密钥;
- base.RawDataAndCheck = new byte[] { (byte)keyType }.Concat(oldKey).Concat(newKey).ToList();
- }
- }
- }
|