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 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
- type MethodID
- type Session
- type SessionOpt
- type StreamToken
- type TPerProperties
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrTooLargeComPacket = errors.New("encountered a too large ComPacket") ErrTooLargePacket = errors.New("encountered a too large Packet") )
View Source
var ( ErrTPerSyncNotSupported = errors.New("synchronous operation not supported by TPer") 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} )
View Source
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, } )
View Source
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 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
func (*MethodCall) Execute ¶
func (m *MethodCall) Execute(c CommunicationIntf, proto drive.SecurityProtocol, ses *Session) ([][]byte, error)
Execute a prepared Method call, returns a list of tokens returned from call.
func (*MethodCall) MarshalBinary ¶
func (m *MethodCall) MarshalBinary() ([]byte, error)
func (*MethodCall) PushBytes ¶
func (m *MethodCall) PushBytes(b []byte)
func (*MethodCall) PushRaw ¶ added in v1.2.0
func (m *MethodCall) PushRaw(b []byte)
func (*MethodCall) PushToken ¶ added in v1.2.0
func (m *MethodCall) PushToken(tok StreamToken)
type Session ¶
type Session struct { ComID ComID TSN, HSN int // See "3.2.3.3.1.2 SeqNumber" SeqLastXmit int SeqLastAcked int SeqNextExpected int // contains filtered or unexported fields }
func NewSession ¶ added in v1.2.0
func NewSession(d DriveIntf, tper *FeatureTPer, opts ...SessionOpt) (*Session, error)
Initiate a new session with a Security Provider
TODO: Let's see if this API makes sense...
type SessionOpt ¶
type SessionOpt func(s *Session)
func WithComID ¶
func WithComID(c ComID) SessionOpt
func WithHSN ¶
func WithHSN(hsn int) SessionOpt
type StreamToken ¶ added in v1.2.0
type StreamToken []byte
var ( StreamStartList StreamToken = []byte{0xF0} StreamEndList StreamToken = []byte{0xF1} StreamStartName StreamToken = []byte{0xF2} StreamEndName StreamToken = []byte{0xF3} StreamCall StreamToken = []byte{0xF8} StreamEndOfData StreamToken = []byte{0xF9} StreamEndOfSession StreamToken = []byte{0xFA} StreamStartTransaction StreamToken = []byte{0xFB} StreamEndTransaction StreamToken = []byte{0xFC} StreamEmptyAtom StreamToken = []byte{0xFF} )
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 }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.