跳到主要内容

6.2. Secret Export (密钥导出)

6.2. Secret Export (密钥导出)

应用程序可能还希望派生仅给定接收者知道的密钥。本节提供了使用第 5.3 节中指定的 API 实现无状态"单次调用"密钥导出的 HPKE API 模板:

def SendExport<MODE>(pkR, info, exporter_context, L, ...):
enc, ctx = Setup<MODE>S(pkR, info, ...)
exported = ctx.Export(exporter_context, L)
return enc, exported

def ReceiveExport<MODE>(enc, skR, info, exporter_context, L, ...):
ctx = Setup<MODE>R(enc, skR, info, ...)
return ctx.Export(exporter_context, L)

如第 6.1 节所述, MODE 模板参数是 Base, PSK, Auth 或 AuthPSK 之一。由 "..." 表示的可选参数取决于 MODE, 可能为空。