open-source-firmware / go-tcg-storage

Go library for interfacing TCG Storage functions on storage devices
BSD 3-Clause "New" or "Revised" License
21 stars 10 forks source link

ErrInvalidPropertiesResponse with WD HUH721212ALE601 #116

Open yar-sh opened 2 months ago

yar-sh commented 2 months ago

Hi! I just got these drives, and they've been nothing but a headache - sedutil-cli doesn't work because they are Enterprise. go-tcg-storage seems to be the only project that gets me somewhere

Here are the commands I'm running:

# ./tcgdiskstat 
2024/06/24 17:31:12 drive.Open(/dev/sda): device does not support TCG Storage Core
DEVICE     MODEL             SERIAL     FIRMWARE   PROTOCOL   SSC          STATE
/dev/sdb   HUH721212ALE601   REDACTED   0002       SATA       Enterprise   lES   
# ./gosedctl initial-setup-enterprise -d /dev/sdb -p debug -b debug -e debug
gosedctl: error: NewControllSession() failed: response was not the expected Properties call format

I've narrowed it down to this specific line: https://github.com/open-source-firmware/go-tcg-storage/blob/main/pkg/core/session.go#L464

Basically, the expected number of params is 5, but for me it's just 1.

I tried bypassing the check, by ignoring the number of params and parseHostProperties. I've substituted the return value on this line to be return *rhp, tp, nil. This did not work:

gosedctl: error: authenticating as AdminSP failed: authentication failed

Do you know what could be an issue? I'll be happy to try out anything for debugging purposes to assist

Extra output from tcgsdiag:

# ./tcgsdiag /dev/sdb
===> DRIVE SECURITY INFORMATION
2024/06/24 17:48:37 Drive identity: Protocol=SATA, Model=HUH721212ALE601, Serial=REDACTED, Firmware=0002
2024/06/24 17:48:37 SecurityProtocols: [0 1 2]
2024/06/24 17:48:37 Drive certificate:
([]*x509.Certificate) <nil>

===> TCG AUTO ComID SELF-TEST
2024/06/24 17:48:37 Allocated ComID 0x00000000
2024/06/24 17:48:37 Unable to validate allocated ComID: operation is not supported

===> TCG FEATURE DISCOVERY
(*core.Level0Discovery)(0xc0001000e0)({
  MajorVersion: (int) 0,
  MinorVersion: (int) 1,
  Vendor: ([32]uint8) (len=32 cap=32) {
    00000000  01 80 00 5f 00 19 00 00  00 00 00 00 00 00 00 00  |..._............|
    00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  },
  TPer: (*feature.TPer)(0xc0000b44c0)({
    SyncSupported: (bool) true,
    AsyncSupported: (bool) false,
    AckNakSupported: (bool) false,
    BufferMgmtSupported: (bool) false,
    StreamingSupported: (bool) true,
    ComIDMgmtSupported: (bool) false
  }),
  Locking: (*feature.Locking)(0xc0000b44d4)({
    LockingSupported: (bool) true,
    LockingEnabled: (bool) false,
    Locked: (bool) false,
    MediaEncryption: (bool) true,
    MBREnabled: (bool) false,
    MBRDone: (bool) false,
    MBRShadowing: (bool) true
  }),
  Geometry: (*feature.Geometry)(0x6d5160)({
  }),
  SecureMsg: (*feature.SecureMsg)(<nil>),
  Enterprise: (*feature.Enterprise)(0xc0000b44f0)({
    CommonSSC: (feature.CommonSSC) {
      BaseComID: (uint16) 2046,
      NumComID: (uint16) 2
    },
    RangeCrossingBehavior: (bool) false
  }),
  OpalV1: (*feature.OpalV1)(<nil>),
  SingleUser: (*feature.SingleUser)(<nil>),
  DataStore: (*feature.DataStore)(<nil>),
  OpalV2: (*feature.OpalV2)(<nil>),
  Opalite: (*feature.Opalite)(<nil>),
  PyriteV1: (*feature.PyriteV1)(<nil>),
  PyriteV2: (*feature.PyriteV2)(<nil>),
  RubyV1: (*feature.RubyV1)(<nil>),
  LockingLBA: (*feature.LockingLBA)(<nil>),
  BlockSID: (*feature.BlockSID)(<nil>),
  NamespaceLocking: (*feature.NamespaceLocking)(<nil>),
  DataRemoval: (*feature.DataRemoval)(<nil>),
  NamespaceGeometry: (*feature.NamespaceGeometry)(<nil>),
  SeagatePorts: (*feature.SeagatePorts)(<nil>),
  UnknownFeatures: ([]uint16) (len=1 cap=4) {
    (uint16) 49152
  }
})

===> TCG ADMIN SP SESSION
2024/06/24 17:48:37 Auto-allocation ComID test failed earlier, selecting first available base ComID
2024/06/24 17:48:37 Selecting Enterprise ComID
2024/06/24 17:48:37 Creating control session with ComID 0x000007fe
2024/06/24 17:48:37 s.NewControlSession failed: response was not the expected Properties call format
2024/06/24 17:48:37 No control session, unable to continue