Documentation
¶
Overview ¶
Package accountkeys implements Signal account-level key derivations.
It is a pure-Go port of upstream libsignal rust/account-keys at v0.96.4. The package deliberately contains no network or storage behavior.
Index ¶
- Constants
- Variables
- func LocalPINHash(pin []byte) (string, error)
- func LocalPINHashWithSalt(pin []byte, salt [localPINSaltLen]byte) string
- func MakePINSalt(username string, groupID uint64) [32]byte
- func VerifyLocalPINHash(encoded string, pin []byte) (bool, error)
- type AccountEntropyPool
- type BackupForwardSecrecyEncryptionKey
- type BackupForwardSecrecyPassword
- type BackupForwardSecrecyToken
- type BackupID
- type BackupKey
- func (k BackupKey) DeriveBackupID(aci address.ServiceID) BackupID
- func (k BackupKey) DeriveECKey(aci address.ServiceID) (curve.PrivateKey, error)
- func (k BackupKey) DeriveForwardSecrecyEncryptionKey(salt []byte) BackupForwardSecrecyEncryptionKey
- func (k BackupKey) DeriveForwardSecrecyPassword(salt []byte) BackupForwardSecrecyPassword
- func (k BackupKey) DeriveLocalBackupMetadataKey() [LocalBackupMetadataKeyLen]byte
- func (k BackupKey) DeriveMediaEncryptionKeyData(mediaID [MediaIDLen]byte) [MediaEncryptionKeyLen]byte
- func (k BackupKey) DeriveMediaID(mediaName string) [MediaIDLen]byte
- func (k BackupKey) DeriveThumbnailTransitEncryptionKeyData(mediaID [MediaIDLen]byte) [MediaEncryptionKeyLen]byte
- type PinHash
Constants ¶
const ( // SVRKeyLen is the length in bytes of a derived SVR master key. SVRKeyLen = 32 // BackupKeyLen is the length in bytes of an account backup key. BackupKeyLen = 32 // LocalBackupMetadataKeyLen is the length in bytes of local backup metadata keys. LocalBackupMetadataKeyLen = 32 // MediaIDLen is the length in bytes of a derived backup media ID. MediaIDLen = 15 // BackupForwardSecrecyTokenLen is the length in bytes of backup forward secrecy tokens. BackupForwardSecrecyTokenLen = 32 // MediaEncryptionKeyLen is the length in bytes of backup media encryption key data. MediaEncryptionKeyLen = 64 )
Variables ¶
var ( // ErrInvalidAccountEntropyPool reports malformed account entropy input. ErrInvalidAccountEntropyPool = errors.New("invalid account entropy pool") // ErrInvalidPHCString reports malformed or unsupported PHC password hash input. ErrInvalidPHCString = errors.New("invalid PHC string") )
Functions ¶
func LocalPINHash ¶
LocalPINHash creates a PHC-encoded local PIN hash with a random salt.
func LocalPINHashWithSalt ¶
LocalPINHashWithSalt creates a PHC-encoded local PIN hash with salt.
func MakePINSalt ¶
MakePINSalt derives a Signal PIN salt from a username and backup group ID.
Types ¶
type AccountEntropyPool ¶
type AccountEntropyPool struct {
// contains filtered or unexported fields
}
AccountEntropyPool stores the 64-character account entropy pool.
func GenerateAccountEntropyPool ¶
func GenerateAccountEntropyPool() (AccountEntropyPool, error)
GenerateAccountEntropyPool creates a new account entropy pool using crypto/rand.
func GenerateAccountEntropyPoolFrom ¶
func GenerateAccountEntropyPoolFrom(r io.Reader) (AccountEntropyPool, error)
GenerateAccountEntropyPoolFrom creates a new account entropy pool using r.
func ParseAccountEntropyPool ¶
func ParseAccountEntropyPool(s string) (AccountEntropyPool, error)
ParseAccountEntropyPool validates and parses a serialized account entropy pool.
func (AccountEntropyPool) Bytes ¶
func (p AccountEntropyPool) Bytes() [accountEntropyPoolLen]byte
Bytes returns the fixed-width byte representation of the account entropy pool.
func (AccountEntropyPool) DeriveSVRKey ¶
func (p AccountEntropyPool) DeriveSVRKey() [SVRKeyLen]byte
DeriveSVRKey derives the account SVR master key.
func (AccountEntropyPool) String ¶
func (p AccountEntropyPool) String() string
type BackupForwardSecrecyEncryptionKey ¶
BackupForwardSecrecyEncryptionKey contains cipher and HMAC keys for backup forward secrecy.
type BackupForwardSecrecyPassword ¶
type BackupForwardSecrecyPassword [32]byte
BackupForwardSecrecyPassword is the PIN-derived forward secrecy password value.
type BackupForwardSecrecyToken ¶
type BackupForwardSecrecyToken [BackupForwardSecrecyTokenLen]byte
BackupForwardSecrecyToken is the token input length used by backup forward secrecy derivations.
type BackupKey ¶
type BackupKey [BackupKeyLen]byte
BackupKey is the root account backup key derived from account entropy.
func DeriveBackupKey ¶
func DeriveBackupKey(p AccountEntropyPool) BackupKey
DeriveBackupKey derives the root backup key from account entropy.
func (BackupKey) DeriveBackupID ¶
DeriveBackupID derives the account backup ID for the given ACI.
func (BackupKey) DeriveECKey ¶
DeriveECKey derives the backup identity private key for the given ACI.
func (BackupKey) DeriveForwardSecrecyEncryptionKey ¶
func (k BackupKey) DeriveForwardSecrecyEncryptionKey(salt []byte) BackupForwardSecrecyEncryptionKey
DeriveForwardSecrecyEncryptionKey derives backup forward secrecy encryption keys.
func (BackupKey) DeriveForwardSecrecyPassword ¶
func (k BackupKey) DeriveForwardSecrecyPassword(salt []byte) BackupForwardSecrecyPassword
DeriveForwardSecrecyPassword derives the backup forward secrecy PIN password.
func (BackupKey) DeriveLocalBackupMetadataKey ¶
func (k BackupKey) DeriveLocalBackupMetadataKey() [LocalBackupMetadataKeyLen]byte
DeriveLocalBackupMetadataKey derives the local backup metadata key.
func (BackupKey) DeriveMediaEncryptionKeyData ¶
func (k BackupKey) DeriveMediaEncryptionKeyData(mediaID [MediaIDLen]byte) [MediaEncryptionKeyLen]byte
DeriveMediaEncryptionKeyData derives backup media encryption key data.
func (BackupKey) DeriveMediaID ¶
func (k BackupKey) DeriveMediaID(mediaName string) [MediaIDLen]byte
DeriveMediaID derives a backup media ID for mediaName.
func (BackupKey) DeriveThumbnailTransitEncryptionKeyData ¶
func (k BackupKey) DeriveThumbnailTransitEncryptionKeyData(mediaID [MediaIDLen]byte) [MediaEncryptionKeyLen]byte
DeriveThumbnailTransitEncryptionKeyData derives backup thumbnail transit encryption key data.