当前位置: 首页 > news >正文

[Kerberos] 简化的加密和校验和总则

基于上一篇:[Kerberos加密和校验和总则]

1. A Key Derivation Function


我们没有定义“protocol key” 由大量加密密钥组成的一些方案,而是使用从 base key 派生的密钥来执行加密操作。

base key 必须只用于生成其他 key。而且这个生成过程必须是不可逆的(non-invertible)并且熵保持的(entropy preserving)。

鉴于这些限制,一个派生密钥的泄露并不会危及其他密钥。

base key 的攻击是非常有限的,因为它仅用于生成其他 key 并且不会用于处理任何用户数据。

从 base key 生成 derived key:

Derived Key = DK(Base Key, Well-Known Constant);

DK(Key, Constant) = random-to-key(DR(Key, Constant));

DR(Key, Constant) = k-truncate(E(Key, Constant, initial-cipher-state));

其中:
    DR 是一个随机序列生成函数 (random-octet generation function)
    DK 是一个 key-derivation 函数
    E(Key, Plaintext, CipherState) 是一个 cipher
    Constant 是由该函数具体用途决定的众所周知的一个常量
    k-truncate 用于从输入中截取前 k 个比特。
    k 是该加密算法所使用的 key generation seed length

Constant 的长度小于 E 的 cipher block size 时, 需要使用 n-fold 函数扩展其长度,以便可以使用相应的 E 来加密它。

当 E 算法的输出长度小于 K时, 则根据需要多次将其加密结果作为输入继续加密,直到达到指定长度。

K1 = E(Key, n-fold(Constant), intial-cipher-state);
K2 = E(Key, K1, initial-cipher-state);
K3 = E(Key, K2, initial-cipher-state);
K4 = ...

DR(Key, Constant) = k-truncate (K1 | K2 | K3 | K4 ...)
    
'|' 表示拼接

n-fold 是一种算法,它采用 m 个输入位并“拉伸”它们,以形成 n 个输出位,每个输入位对输出的贡献相等,

We first define a primitive called n-folding, which takes a variable-length input block and produces a fixed-length output sequence. The intent is to give each input bit approximately equal weight in determining the value of each output bit. Note that whenever we need to treat a string of octets as a number, the assumed representation is Big-Endian – Most Significant Byte first.

To n-fold a number X, replicate the input value to a length that is the least common multiple of n and the length of X. Before each repetition, the input is rotated to the right by 13 bit positions. The successive n-bit chunks are added together using 1’s-complement addition (that is, with end-around carry) to yield a n-bit result…

在这里, n-fold 总是被用于输出一个 c 位的输出, c 是 E 算法的 cipher block size。

当 E 的 block size 小于 random-to-key 要求的输入长度时, 需要重复调用 E(将前一次的结果作为下一次的输入), 直到输出长度达到 random-to-key 要求的输入长度。


2. 简化总则


  1. protocol key format

  2. string-to-key function

  3. default string-to-key parameters

  4. key-generation seed length, k

  5. random-to-key function

    保持不变

  6. unkeyed hash algorithm, H

    这应该是一种具有固定大小输出的抗碰撞哈希算法(collision-resistant hash algorithm),适合在 HMAC 中使用.

    它必须支持任意长度的输入。其输出必须至少为 message block size。

  7. HMAC output size, h

    这表示的在传输的消息中使用的 HMAC 函数输出的前导字符串的长度。

    它应该至少是哈希函数 H 输出大小的一半, 至少 80 位。

  8. message block size, m

    这是当前加密算法能处理的最小单元的大小。

    消息将被填充为此大小的倍数。

    当一个加密算法可以处理非块大小整数倍的数据时(例如 CTS 模式)则该值位 1 字节。

    对于传统的带有填充的 CBC 模式, 它的值是底层加密算法的块大小。

  9. encryption/decryption functions, E and D

    这些是针对大小为消息块大小倍数的消息的基本加密和解密函数。

    这里不应包括完整性检查或confounder。

  10. cipher block size, c

    这是底层加密和解密算法所使用分组加密算法的块大小, 用于密钥派生以及消息 confounder 和初始向量的大小。


3. 基于简化总则的密码系统


使用上述的 key derivation函数生成三个中间密钥(intermediate keys):

  1. 一个用于计算原始明文数据的检验和
  2. 其他两个用于加密和计算密文的检验和

最终输出的密文是以下部分拼接构成:

  1. 加密函数 E 的输出
  2. 使用哈希函数 H 的 HMAC 的输出(可能是截断的,只用前面特定长度)

其中明文加密前, 需要添加前缀 confounder 和 后缀必要的填充以便消息长度是消息块大小的整数倍。

protocol key format和总则相同
specific key structure三个 key: { Kc, Ke, Ki }
key-generation seed length和总则相同
required checksum mechanism如下
cipher stateIV 初始化向量
initial cipher state所有位为 0
encryption functionconf = Random string of length c
pad = Shortest string to bring counder and plaintext to a length that's a multiple of m
`(C1, newIV) = E(Ke, config
decryption function(C1, H1) = ciphertext
(P1, newIV) = D(Ke, C1, oldstate.ivec)
if (H1 != HMAC(Ki, P1)[1..h])
--report error
newstate.ivec = newIV
default string-to-key params和总则相同
pseudo-random functiontmp1 = H(octet-string)
tmp2 = truncate tmp1 to multiple of m
PRF = E(DK(protocol-key, prfconstant), tmp2, intial-cipher-state)
PRF 中使用的 prfconstant 是一个三字节的字符串 "prf".
key generation functions:
string-to-key function和总则相同
random-to-key function和总则相同
key-derivation function在 DK 中使用的 "“well-known constant” 是 key usage number. 采用大端编码转为 4字节长度的数组, 外加一个额外的字节, 如下:
`Kc = DK(base-key, usage

4. 基于简化总则的检验和


当使用以上简化的密码系统时, 检验和可以为定义如下:

associated cryptosystem如上
get_micHMAC(Kc, message)[1..h]
verify_micget_mic 然后对比结果

相关文章:

  • MYSQL8.0以上版本 主从复制
  • C++11QT复习 (十)
  • 中科驭数受邀参展2025中关村论坛 DPU受主流媒体关注
  • 从 Java 到 Go:面向对象的巨人与云原生的轻骑兵
  • [250331] Paozhu 发布 1.9.0:C++ Web 框架,比肩脚本语言 | DeaDBeeF 播放器发布 1.10.0
  • Java 应用程序CPU 100%问题排查优化实战
  • Linux centos 7 常用服务器搭建
  • kubernetes安装部署k8s
  • RK3588使用笔记:导出做好的文件系统
  • Pytorch 张量操作
  • windowsmacOs安装minio
  • RAG系统实战:当检索为空时,如何实现生成模块的优雅降级(Fallback)?
  • 【JAVA】【疑难杂症解决!】org.springframework.transaction.UnexpectedRollbackException:
  • Mybatis-Plus学习笔记
  • Maven安装与配置完整指南
  • 学习记录706@微信小程序+springboot项目 真机测试 WebSocket错误: {errMsg: Invalid HTTP status.}连接不上
  • MySQL(二)
  • Docker使用官方镜像/国内镜像源(阿里云、华为云 安装 MySQL 5.7
  • 智能文档解析专家
  • AI应用案例(1)——智能工牌和会话质检
  • 第一集|好饭不怕晚,折腰若如初见
  • 基金经理调仓引发大金融板块拉升?公募新规落地究竟利好哪些板块
  • 国务院关税税则委员会关于调整对原产于美国的进口商品加征关税措施的公告
  • 特朗普开启第二任期首次外访:中东行主打做生意,不去以色列
  • 全国汽车以旧换新补贴申请量突破1000万份
  • 美英贸易协议|不,这不是一份重大贸易协议