Private/Crypto/Get-SecretSharingCipherSaltPrefix.ps1
|
function Get-SecretSharingCipherSaltPrefix { <# .SYNOPSIS Builds the SLIP-0039 salt prefix used by the master-secret Feistel cipher. .DESCRIPTION Non-extendable backups mix the ASCII string "shamir" and the 15-bit share-set identifier (as 2 big-endian bytes) into every round's PBKDF2 salt, binding the encryption to that specific share set. Extendable backups use an empty prefix so shares can be added to a set after the fact without invalidating existing ones. #> [CmdletBinding()] [OutputType([byte[]], [System.Object[]])] param( [Parameter(Mandatory)] [ValidateRange(0, 32767)] [int]$Identifier, [switch]$Extendable ) if ($Extendable) { return , ([byte[]]@()) } $constant = Get-SecretSharingCipherConstant $identifierByte = [byte[]]( [byte](($Identifier -shr 8) -band 0xFF), [byte]($Identifier -band 0xFF) ) return , ([byte[]]($constant.CustomizationString + $identifierByte)) } |