Documentation
¶
Overview ¶
Package rpmb implements Replay Protected Memory Block (RPMB) configuration and control on eMMCs accessed through TamaGo NXP uSDHC driver.
This package is only meant to be used with `GOOS=tamago GOARCH=arm` as supported by the TamaGo framework for bare metal Go on ARM SoCs, see https://github.com/usbarmory/tamago.
The API supports mitigations for CVE-2020-13799 as described in the whitepaper linked at:
https://www.westerndigital.com/support/productsecurity/wdc-20008-replay-attack-vulnerabilities-rpmb-protocol-applications
Index ¶
Constants ¶
const ( AuthenticationKeyProgramming = iota + 1 WriteCounterRead AuthenticatedDataWrite AuthenticatedDataRead ResultRead AuthenticatedDeviceConfigurationWrite AuthenticatedDeviceConfigurationRead )
p99, Table 18 — RPMB Request/Response Message Types, JESD84-B51
const ( OperationOK = iota GeneralFailure AuthenticationFailure CounterFailure AddressFailure WriteFailure ReadFailure AuthenticationKeyNotYetProgrammed )
p100, Table 20 — RPMB Operation Results, JESD84-B51
const (
FrameLength = 512
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // compute request MAC before sending RequestMAC bool // validate response MAC after receiving ResponseMAC bool // set Nonce field with random value RandomNonce bool // get response with a result read request ResultRead bool }
Request configuration
type DataFrame ¶
type DataFrame struct { StuffBytes [196]byte KeyMAC [32]byte Data [256]byte Nonce [16]byte WriteCounter [4]byte Address [2]byte BlockCount [2]byte Result [2]byte Resp byte Req byte }
p98, Table 17 — Data Frame Files for RPMB, JESD84-B51
type OperationError ¶
type OperationError struct {
Result uint16
}
func (*OperationError) Error ¶
func (e *OperationError) Error() string
type RPMB ¶
RPMB defines a Replay Protected Memory Block partition access instance.
func Init ¶
Init returns a new RPMB instance for a specific MMC card and MAC key. The dummyBlock argument is an unused sector, required for CVE-2020-13799 mitigation to invalidate uncommitted writes.
func (*RPMB) Counter ¶
Counter returns the RPMB partition write counter, the argument boolean indicates whether the read operation should be authenticated.
func (*RPMB) ProgramKey ¶
ProgramKey programs the RPMB partition authentication key.
*WARNING*: this is a one-time irreversible operation for the specific MMC card associated to the RPMB partition instance.
func (*RPMB) Read ¶
Read performs an authenticated data transfer from the card RPMB partition, the input buffer can contain up to 256 bytes of data.
func (*RPMB) Write ¶
Write performs an authenticated data transfer to the card RPMB partition, the input buffer can contain up to 256 bytes of data.
The write operation mitigates CVE-2020-13799 by verifying that the response counter is equal to a single increment of the request counter, otherwise an error is returned.