Documentation
¶
Index ¶
- func AuthCodeMultiSession(authType types.AuthType, password []byte, sessionID, sessionSeq uint32, ...) []byte
- func AuthCodeSingleSession(authType types.AuthType, password []byte, sessionID uint32, challenge []byte) []byte
- func AuthHMAC(alg types.AuthAlg, data, key []byte) ([]byte, error)
- func DecryptAES(cipherText, cipherKey, iv []byte) ([]byte, error)
- func DecryptAESPayload(cipherText, k2 []byte) ([]byte, error)
- func DecryptRC4(cipherText, cipherKey, iv []byte) ([]byte, error)
- func DeriveK1(authAlg types.AuthAlg, sik []byte) ([]byte, error)
- func DeriveK2(authAlg types.AuthAlg, sik []byte) ([]byte, error)
- func DeriveSIK(authAlg types.AuthAlg, consoleRand, bmcRand []byte, role uint8, ...) ([]byte, error)
- func DeriveSessionKeys(authAlg types.AuthAlg, consoleRand, bmcRand []byte, role uint8, ...) (sik, k1, k2 []byte, err error)
- func EncryptAES(plainText, cipherKey, iv []byte) ([]byte, error)
- func EncryptAESPayload(plain, k2, iv []byte) ([]byte, error)
- func EncryptRC4(plainText, cipherKey, _ []byte) ([]byte, error)
- func Equal(a, b []byte) bool
- func HMAC(alg string, data, key []byte) ([]byte, error)
- func IntegrityAuthCodeLen(alg types.IntegrityAlg) (int, bool)
- func IntegrityHMAC(alg types.IntegrityAlg, data, key []byte) ([]byte, error)
- func PadAES(plain []byte) []byte
- func PadPassword20(password []byte) []byte
- func RAKP2AuthCode(authAlg types.AuthAlg, consoleID, bmcID uint32, ...) ([]byte, error)
- func RAKP2AuthCodeLen(alg types.AuthAlg) int
- func RAKP3AuthCode(authAlg types.AuthAlg, bmcRand []byte, consoleID uint32, role uint8, ...) ([]byte, error)
- func RAKP3AuthCodeLen(alg types.AuthAlg) int
- func RAKP4ICV(authAlg types.AuthAlg, consoleRand []byte, bmcID uint32, bmcGUID, sik []byte) ([]byte, error)
- func RAKP4ICVLen(alg types.AuthAlg) int
- func RandomBytes(n int) []byte
- func SessionIntegrityAuthCode(alg types.IntegrityAlg, input, k1 []byte, password string) ([]byte, error)
- func TruncateRAKP2AuthCode(alg types.AuthAlg, full []byte) ([]byte, error)
- func UnpadAES(padded []byte) ([]byte, error)
- func VerifyMultiSessionAuthCode(authType types.AuthType, password []byte, sessionID, sessionSeq uint32, ...) bool
- type MultiSessionInput
- type SingleSessionInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthCodeMultiSession ¶
func AuthCodeMultiSession(authType types.AuthType, password []byte, sessionID, sessionSeq uint32, ipmiData []byte) []byte
AuthCodeMultiSession computes the multi-session session-header AuthCode.
func AuthCodeSingleSession ¶
func AuthCodeSingleSession(authType types.AuthType, password []byte, sessionID uint32, challenge []byte) []byte
AuthCodeSingleSession computes the Activate Session AuthCode.
func AuthHMAC ¶
AuthHMAC selects the HMAC variant based on the RAKP authentication algorithm (v2.0§13.28). Returns the full digest (RAKP2/RAKP3 and SIK/K1/K2 use the full digest; RAKP4 truncates separately).
func DecryptAES ¶
DecryptAES decrypts cipherText with AES-CBC.
func DecryptAESPayload ¶
DecryptAESPayload decrypts an AES-CBC-128 confidential payload and strips §13.29 padding. Wire format: IV(16) || ciphertext.
func DecryptRC4 ¶
DecryptRC4 is identical to EncryptRC4 for RC4 (XOR stream).
func DeriveSIK ¶
func DeriveSIK(authAlg types.AuthAlg, consoleRand, bmcRand []byte, role uint8, username string, kgOrKuid []byte) ([]byte, error)
DeriveSIK computes the Session Integrity Key (v2.0§13.31):
SIK = HMAC(Kg or Kuid, ConsoleRand || BMCRand || Role || UserLen || Username)
kgOrKuid should be Kg when configured, otherwise the 20-byte padded password.
func DeriveSessionKeys ¶
func DeriveSessionKeys(authAlg types.AuthAlg, consoleRand, bmcRand []byte, role uint8, username string, kgOrKuid []byte) (sik, k1, k2 []byte, err error)
DeriveSessionKeys computes SIK, K1, and K2 from session parameters.
func EncryptAES ¶
EncryptAES encrypts plainText (must be block-aligned) with AES-CBC. cipherKey must be 16, 24, or 32 bytes (AES-128/192/256).
Spec: v2.0§13.29 Encryption with AES.
func EncryptAESPayload ¶
EncryptAESPayload encrypts an IPMI confidential payload with AES-CBC-128. k2 is the session K2 key; the first 16 bytes are used as the cipher key. iv must be 16 bytes (caller supplies or uses RandomBytes). Wire format: IV(16) || ciphertext.
func EncryptRC4 ¶
EncryptRC4 / DecryptRC4 apply the RC4 stream cipher (xRC4 confidentiality, v2.0§13.30). IV is unused by the cipher itself but kept in the signature for call-site parity with the AES helpers.
func IntegrityAuthCodeLen ¶
func IntegrityAuthCodeLen(alg types.IntegrityAlg) (int, bool)
IntegrityAuthCodeLen returns the AuthCode (integrity data) field length for alg (v2.0§13.28.4). ok is false for unknown algorithms.
func IntegrityHMAC ¶
func IntegrityHMAC(alg types.IntegrityAlg, data, key []byte) ([]byte, error)
IntegrityHMAC selects the HMAC variant based on the session integrity algorithm (v2.0§13.28.4). Returns the full digest; callers truncate.
func PadAES ¶
PadAES pads plain to a multiple of 16 bytes per IPMI 2.0 spec §13.29:
plain || pad bytes (1,2,3,...) || pad-length byte
func PadPassword20 ¶
PadPassword20 returns the user password padded to 20 bytes (Kuid). Spec: v2.0§13.31 (RAKP key exchange uses 160-bit Kuid).
func RAKP2AuthCode ¶
func RAKP2AuthCode(authAlg types.AuthAlg, consoleID, bmcID uint32, consoleRand, bmcRand, bmcGUID []byte, role uint8, username string, kuid []byte) ([]byte, error)
RAKP2AuthCode generates the Key Exchange Authentication Code for RAKP Message 2 (v2.0§13.31):
HMAC(Kuid, ConsoleID || BMCID || ConsoleRand || BMCRand || BMCGUID || Role || UserLen || Username)
func RAKP2AuthCodeLen ¶
RAKP2AuthCodeLen returns the expected Key Exchange Authentication Code length in RAKP Message 2 for the given authentication algorithm.
func RAKP3AuthCode ¶
func RAKP3AuthCode(authAlg types.AuthAlg, bmcRand []byte, consoleID uint32, role uint8, username string, kuid []byte) ([]byte, error)
RAKP3AuthCode generates the auth code for RAKP Message 3 (v2.0§13.31):
HMAC(Kuid, BMCRand || ConsoleID || Role || UserLen || Username)
func RAKP3AuthCodeLen ¶
RAKP3AuthCodeLen returns the expected auth code length in RAKP Message 3.
func RAKP4ICV ¶
func RAKP4ICV(authAlg types.AuthAlg, consoleRand []byte, bmcID uint32, bmcGUID, sik []byte) ([]byte, error)
RAKP4ICV generates the Integrity Check Value for RAKP Message 4.
HMAC input (v2.0§13.31): ConsoleRand || BMCID || BMCGUID
Per v2.0§13.28.1 / §13.28.1b the ICV truncation is selected by the *authentication* algorithm (not the session integrity algorithm), using SIK as the HMAC key:
- RAKP-HMAC-SHA1 → HMAC-SHA1-96 (12 bytes)
- RAKP-HMAC-SHA256 → HMAC-SHA256-128 (16 bytes)
- RAKP-HMAC-MD5 → HMAC-MD5-128 (16 bytes)
- RAKP-none → absent
func RAKP4ICVLen ¶
RAKP4ICVLen returns the expected Integrity Check Value length in RAKP Message 4.
func RandomBytes ¶
RandomBytes returns n cryptographically random bytes. Panics if crypto/rand is unavailable (same contract as prior client/server helpers).
func SessionIntegrityAuthCode ¶
func SessionIntegrityAuthCode(alg types.IntegrityAlg, input, k1 []byte, password string) ([]byte, error)
SessionIntegrityAuthCode computes the AuthCode for an authenticated RMCP+ session packet (v2.0§13.28.4). Truncation matches the integrity algorithm:
- HMAC-SHA1-96 → 12 bytes
- HMAC-MD5-128 / HMAC-SHA256-128 → 16 bytes
- MD5-128 → MD5(password || input || password), 16 bytes
password is only used for IntegrityAlg_MD5_128; HMAC variants use k1.
func TruncateRAKP2AuthCode ¶
TruncateRAKP2AuthCode truncates a full AuthHMAC digest to the RAKP2 wire length.
Types ¶
type MultiSessionInput ¶
type MultiSessionInput struct {
Password string
SessionID uint32
SessionSeq uint32
IPMIData []byte
}
MultiSessionInput is the AuthCode carried in the v1.5 session header for authenticated packets (v1.5§18.15.1 / v2.0§22.17.1).
type SingleSessionInput ¶
SingleSessionInput is the AuthCode carried in Activate Session request data (v1.5§18.15.1 / v2.0§22.17.1).