p25crypto

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package p25crypto generates the keystreams P25's link-layer encryption algorithms produce from a key and a Message Indicator (IV). It exists so the assessment harness can actually *attempt decryption* — generate the real keystream for a candidate/known/weak key and XOR it onto captured ciphertext — rather than only detecting structural weaknesses.

The constructions follow the common open P25 implementations (OP25, DSD-FME):

  • ADP (RC4, ALGID 0xAA): RC4 keyed with the 5-octet key followed by the first 8 octets of the MI, discarding the first 256 keystream bytes.
  • DES-OFB (0x81): single-DES in OFB, IV = first 8 octets of the MI.
  • AES-128/256 (0x85 / 0x84 / 0x89): AES in OFB, IV = the MI left-justified into a 16-byte block.

These are the byte-stream keystreams; mapping them onto a specific protocol payload (e.g. the exact IMBE voice-bit positions) is the caller's concern. The package performs no key recovery — it only realises a keystream for a key the caller already has or is testing.

Index

Constants

View Source
const (
	AlgDESOFB    = 0x81
	AlgTDES2     = 0x83 // two-key Triple-DES (K1,K2 → K1K2K1)
	AlgAES256    = 0x84
	AlgAES128    = 0x85
	AlgTDES      = 0x86 // three-key Triple-DES
	AlgAES256OFB = 0x89
	AlgADP       = 0xAA
)

P25 algorithm identifiers (TIA-102.AACE-A). Mirrors internal/radio/p25/algorithm.go; duplicated here to keep the engine dependency-light.

Variables

This section is empty.

Functions

func AlgName

func AlgName(algid uint8) string

AlgName returns a short human label for algid.

func DefaultKeys

func DefaultKeys(algid uint8) [][]byte

DefaultKeys returns a small dictionary of weak / default / test keys to try for algid: the all-zero key, the all-FF key, and a simple incrementing pattern. These are the keys a misconfigured or factory-default radio is most likely to carry. Returns nil for unsupported algorithms.

func KeySize

func KeySize(algid uint8) int

KeySize returns the key length in bytes p25crypto expects for algid, or 0 when the algorithm is not supported here.

func Keystream

func Keystream(algid uint8, key, mi []byte, n int) ([]byte, error)

Keystream returns n bytes of keystream for the given algorithm, key, and message indicator (IV). It validates the key length against KeySize.

func Supported

func Supported(algid uint8) bool

Supported reports whether Keystream can realise this algorithm.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL