Documentation
¶
Index ¶
- Variables
- func HandleComIDRequest(d DriveIntf, comID ComID, req ComIDRequest) ([]byte, error)
- func IsComIDValid(d DriveIntf, comID ComID) (bool, error)
- func NewPlainCommunication(d DriveIntf, hp HostProperties, tp TPerProperties) *plainCom
- func StackReset(d DriveIntf, comID ComID) error
- type ComID
- type ComIDRequest
- type CommunicationIntf
- type ControlSession
- type ControlSessionOpt
- type DriveIntf
- type FeatureBlockSID
- type FeatureCode
- type FeatureDataRemoval
- type FeatureDataStore
- type FeatureEnterprise
- type FeatureGeometry
- type FeatureLocking
- type FeatureLockingLBA
- type FeatureNamespaceGeometry
- type FeatureNamespaceLocking
- type FeatureOpalV1
- type FeatureOpalV2
- type FeatureOpalite
- type FeaturePyriteV1
- type FeaturePyriteV2
- type FeatureRubyV1
- type FeatureSecureMsg
- type FeatureSingleUser
- type FeatureTPer
- type HostProperties
- type InvokingID
- type Level0Discovery
- type MethodCall
- func (m *MethodCall) EndList()
- func (m *MethodCall) EndOptionalParameter()
- func (m *MethodCall) Execute(c CommunicationIntf, proto drive.SecurityProtocol, ses *Session) ([]interface{}, error)
- func (mo *MethodCall) MarshalBinary() ([]byte, error)
- func (m *MethodCall) NamedUInt(name string, val uint)
- func (m *MethodCall) PushBytes(b []byte)
- func (m *MethodCall) StartList()
- func (m *MethodCall) StartOptionalParameter(id uint)
- type MethodID
- type Session
- type SessionOpt
- type TPerProperties
Constants ¶
This section is empty.
Variables ¶
var ( ErrTooLargeComPacket = errors.New("encountered a too large ComPacket") ErrTooLargePacket = errors.New("encountered a too large Packet") )
var ( ErrTPerSyncNotSupported = errors.New("synchronous operation not supported by TPer") ErrInvalidPropertiesResponse = errors.New("response was not the expected properties call") ErrPropertiesCallFailed = errors.New("the properties call returned non-zero") InvokeIDSMU InvokingID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF} // Table 241 - "Session Manager Method UIDs" MethodIDSMProperties MethodID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01} MethodIDSMStartSession MethodID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02} MethodIDSMSyncSession MethodID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03} MethodIDSMStartTrustedSession MethodID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04} MethodIDSMSyncTrustedSession MethodID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x05} MethodIDSMCloseSession MethodID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x06} )
var ( // Table 168: "Communications Initial Assumptions" InitialTPerProperties = TPerProperties{ MaxSubpackets: 1, MaxPacketSize: 1004, MaxPackets: 1, MaxComPacketSize: 1024, MaxIndTokenSize: 968, MaxAggTokenSize: 968, MaxMethods: 1, ContinuedTokens: false, SequenceNumbers: false, AckNak: false, Asynchronous: false, } // Increased to match that one of the highest standard we support InitialHostProperties = HostProperties{ MaxSubpackets: 1, MaxPacketSize: 2028, MaxPackets: 1, MaxComPacketSize: 2048, MaxIndTokenSize: 1992, MaxAggTokenSize: 1992, MaxMethods: 1, ContinuedTokens: false, SequenceNumbers: false, AckNak: false, Asynchronous: false, } )
var (
ErrNoOpalV2Support = errors.New("device does not support Opal 2.0")
)
Functions ¶
func HandleComIDRequest ¶
func HandleComIDRequest(d DriveIntf, comID ComID, req ComIDRequest) ([]byte, error)
func NewPlainCommunication ¶
func NewPlainCommunication(d DriveIntf, hp HostProperties, tp TPerProperties) *plainCom
Low-level communication used to send/receive packets to a TPer or SP.
Implements Subpacket-Packet-ComPacket packet format.
func StackReset ¶
Reset the state of the synchronous protocol stack.
Types ¶
type ComIDRequest ¶
type ComIDRequest [4]byte
var ( ComIDRequestVerifyComIDValid ComIDRequest = [4]byte{0x00, 0x00, 0x00, 0x01} ComIDRequestStackReset ComIDRequest = [4]byte{0x00, 0x00, 0x00, 0x02} ErrNotSupported = errors.New("device does not support TCG Storage Core") )
type CommunicationIntf ¶
type CommunicationIntf interface { Send(proto drive.SecurityProtocol, ses *Session, data []byte) error Receive(proto drive.SecurityProtocol, ses *Session) ([]byte, error) }
NOTE: This is almost io.ReadWriter, but not quite - I couldn't figure out a good interface use that wouldn't result in a lot of extra copying.
type ControlSession ¶
type ControlSession struct { Session HostProperties HostProperties TPerProperties TPerProperties }
func NewControlSession ¶
func NewControlSession(d DriveIntf, tper *FeatureTPer, opts ...ControlSessionOpt) (*ControlSession, error)
Initiate a new control session with a ComID.
func (*ControlSession) Close ¶
func (cs *ControlSession) Close() error
func (*ControlSession) NewSession ¶
func (cs *ControlSession) NewSession(opts ...SessionOpt) (*Session, error)
Initiate a new session with a Security Provider
type ControlSessionOpt ¶
type ControlSessionOpt func(s *ControlSession)
func WithComID ¶
func WithComID(c ComID) ControlSessionOpt
type DriveIntf ¶
type DriveIntf interface { IFRecv(proto drive.SecurityProtocol, sps uint16, data *[]byte) error IFSend(proto drive.SecurityProtocol, sps uint16, data []byte) error }
type FeatureBlockSID ¶
type FeatureBlockSID struct { }
type FeatureCode ¶
type FeatureCode uint16
const ( FeatureCodeTPer FeatureCode = 0x0001 FeatureCodeLocking FeatureCode = 0x0002 FeatureCodeGeometry FeatureCode = 0x0003 FeatureCodeSecureMsg FeatureCode = 0x0004 FeatureCodeEnterprise FeatureCode = 0x0100 FeatureCodeOpalV1 FeatureCode = 0x0200 FeatureCodeSingleUser FeatureCode = 0x0201 FeatureCodeDataStore FeatureCode = 0x0202 FeatureCodeOpalV2 FeatureCode = 0x0203 FeatureCodeOpalite FeatureCode = 0x0301 FeatureCodePyriteV1 FeatureCode = 0x0302 FeatureCodePyriteV2 FeatureCode = 0x0303 FeatureCodeRubyV1 FeatureCode = 0x0304 FeatureCodeLockingLBA FeatureCode = 0x0401 FeatureCodeBlockSID FeatureCode = 0x0402 FeatureCodeNamespaceLocking FeatureCode = 0x0403 FeatureCodeDataRemoval FeatureCode = 0x0404 FeatureCodeNamespaceGeometry FeatureCode = 0x0405 )
type FeatureDataRemoval ¶
type FeatureDataRemoval struct { }
type FeatureDataStore ¶
type FeatureDataStore struct { }
type FeatureEnterprise ¶
type FeatureEnterprise struct { }
type FeatureGeometry ¶
type FeatureGeometry struct { }
type FeatureLocking ¶
type FeatureLockingLBA ¶
type FeatureLockingLBA struct { }
type FeatureNamespaceGeometry ¶
type FeatureNamespaceGeometry struct { }
type FeatureNamespaceLocking ¶
type FeatureNamespaceLocking struct { }
type FeatureOpalV1 ¶
type FeatureOpalV1 struct { }
type FeatureOpalV2 ¶
type FeatureOpalite ¶
type FeatureOpalite struct { }
type FeaturePyriteV1 ¶
type FeaturePyriteV2 ¶
type FeatureRubyV1 ¶
type FeatureRubyV1 struct { }
type FeatureSecureMsg ¶
type FeatureSecureMsg struct { }
type FeatureSingleUser ¶
type FeatureSingleUser struct { }
type FeatureTPer ¶
type HostProperties ¶
type InvokingID ¶
type InvokingID [8]byte
var ( InvokeIDNull InvokingID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} InvokeIDThisSP InvokingID = [8]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01} )
type Level0Discovery ¶
type Level0Discovery struct { MajorVersion int MinorVersion int Vendor [32]byte TPer *FeatureTPer Locking *FeatureLocking Geometry *FeatureGeometry SecureMsg *FeatureSecureMsg Enterprise *FeatureEnterprise OpalV1 *FeatureOpalV1 SingleUser *FeatureSingleUser DataStore *FeatureDataStore OpalV2 *FeatureOpalV2 Opalite *FeatureOpalite PyriteV1 *FeaturePyriteV1 PyriteV2 *FeaturePyriteV2 RubyV1 *FeatureRubyV1 LockingLBA *FeatureLockingLBA BlockSID *FeatureBlockSID NamespaceLocking *FeatureNamespaceLocking DataRemoval *FeatureDataRemoval NamespaceGeometry *FeatureNamespaceGeometry UnknownFeatures []uint16 }
func Discovery0 ¶
func Discovery0(d DriveIntf) (*Level0Discovery, error)
Perform a Level 0 SSC Discovery.
type MethodCall ¶
type MethodCall struct {
// contains filtered or unexported fields
}
func NewMethodCall ¶
func NewMethodCall(iid InvokingID, mid MethodID) *MethodCall
Prepare a new method call
func (*MethodCall) EndList ¶
func (m *MethodCall) EndList()
func (*MethodCall) EndOptionalParameter ¶
func (m *MethodCall) EndOptionalParameter()
func (*MethodCall) Execute ¶
func (m *MethodCall) Execute(c CommunicationIntf, proto drive.SecurityProtocol, ses *Session) ([]interface{}, error)
Execute a prepared Method call, returns a list of tokens returned from call.
func (*MethodCall) MarshalBinary ¶
func (mo *MethodCall) MarshalBinary() ([]byte, error)
Marshal the complete method call to the data stream representation
func (*MethodCall) NamedUInt ¶
func (m *MethodCall) NamedUInt(name string, val uint)
func (*MethodCall) PushBytes ¶
func (m *MethodCall) PushBytes(b []byte)
Add bytes to the method call
func (*MethodCall) StartList ¶
func (m *MethodCall) StartList()
func (*MethodCall) StartOptionalParameter ¶
func (m *MethodCall) StartOptionalParameter(id uint)
From "3.2.1.2 Method Signature Pseudo-code" Optional parameters are submitted to the method invocation as Named value pairs. The Name portion of the Named value pair SHALL be a uinteger. Starting at zero, these uinteger values are assigned based on the ordering of the optional parameters as defined in this document.
type Session ¶
type TPerProperties ¶
type TPerProperties struct { MaxMethods uint MaxSubpackets uint MaxPacketSize uint MaxPackets uint MaxComPacketSize uint MaxResponseComPacketSize *uint MaxSessions *uint MaxReadSessions *uint MaxIndTokenSize uint MaxAggTokenSize uint MaxAuthentications *uint MaxTransactionLimit *uint DefSessionTimeout *uint MaxSessionTimeout *uint MinSessionTimeout *uint DefTransTimeout *uint MaxTransTimeout *uint MinTransTimeout *uint MaxComIDTime *uint ContinuedTokens bool SequenceNumbers bool AckNak bool Asynchronous bool }