Exemplo n.º 1
0
    def test_getPskEntry_psk_Sedobject(self):

        psk = {'Name': 'sample'}
        l1 = SedObject(psk)
        # kwrv contains the TlsPsk object with values read reflected from the TCG specification
        self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {
            'CipherSuite':
            '0xaa',
            'CommonName':
            '',
            'Enabled':
            0,
            'Name':
            'TLS_PSK_Key0',
            'UID':
            '0000001e00000001'
        })
        p = self.sed.getPskEntry(l1)
        kwrv = self.psk_convert(kwrv)
        mocked_return = SedObject(kwrv)
        assert p.Enabled == mocked_return.Enabled
        assert p.CommonName == mocked_return.CommonName
        assert p.Name == mocked_return.Name
        assert p.UID == mocked_return.UID
        assert p.CipherSuite == mocked_return.CipherSuite
Exemplo n.º 2
0
 def test_setPskEntry_success_psk_SedObject(self):
         
     sample_psk_object = {'Name':'sample'}
     authAs = [(self.sed.auth_SID, self.sed_dev), (self.sed.auth_Erasemaster, self.sed_dev)]
     self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {})
     l1 = SedObject(sample_psk_object)
     self.assertTrue(self.sed.setPskEntry(l1, authAs=authAs, Enabled=True, CipherSuite=self.sed.CipherSuite, PSK=self.sed.uid_bytes))
Exemplo n.º 3
0
 def test_retrieve_LockingInfo_table_success(self):
     
     # kwrv contains the LockingInfo table for Enterprise drives
     self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {'MaxRanges': 31, 
                                                                 'UID': '\x00\x00\x08\x01\x00\x00\x00\x01', 
                                                                 'LowestAlignedLBA': 0, 
                                                                 'EncryptSupport': 1, 
                                                                 'RowNumber': 0, 
                                                                 'LogicalBlockSize': 512, 
                                                                 'AlignmentRequired': 1, 
                                                                 'Version': 10, 
                                                                 'AlignmentGranularity': 8, 
                                                                 'KeysAvailableCfg': 0, 
                                                                 'MaxReEncryptions': 0, 
                                                                 'Name': 'Seagate SED'})
     
     li = self.sed.lockingInfo()
     test_obj = SedObject(kwrv)
     assert li.LogicalBlockSize == test_obj.LogicalBlockSize
     assert li.MaxReEncryptions == test_obj.MaxReEncryptions
     assert li.EncryptSupport == test_obj.EncryptSupport
     assert li.AlignmentGranularity == test_obj.AlignmentGranularity
     assert li.AlignmentRequired == test_obj.AlignmentRequired
     assert li.KeysAvailableCfg == test_obj.KeysAvailableCfg
     assert li.MaxRanges == test_obj.MaxRanges
     assert li.Name == test_obj.Name
     assert li.RowNumber == test_obj.RowNumber
     assert li.Version == test_obj.Version
     assert li.UID == test_obj.UID
Exemplo n.º 4
0
    def test_getRange_success_opal(self):

        # kwrv contains the range object for Opal drives
        self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {0: '\x00\x00\x08\x02\x00\x03\x00\x01', 
                                                                       1: 'Locking_Range1', 
                                                                       2: '', 
                                                                       3: 8, 
                                                                       4: 64, 
                                                                       5: 1, 
                                                                       6: 1, 
                                                                       7: 0, 
                                                                       8: 0, 
                                                                       9: [0], 
                                                                       10: '\x00\x00\x08\x06\x00\x03\x00\x01', 
                                                                       4294901760: 0})

        r1, r2 = (self.sed.getRange(self.sed.rangeNo,self.sed.auth_Admin,authAs=(self.sed.auth_Admin,self.sed_dev)))
        x = self.range_convert(kwrv)
        l1 = SedObject(x)
        l2 = True
        assert r1.Name == l1.Name
        assert r1.RangeStart == l1.RangeStart
        assert r1.RangeLength == l1.RangeLength
        assert r1.LockOnReset == l1.LockOnReset
        assert r1.ReadLockEnabled == l1.ReadLockEnabled
        assert r1.RangeStart == l1.RangeStart
        assert r1.WriteLockEnabled == l1.WriteLockEnabled
        assert r1.ReadLocked == l1.ReadLocked
        assert r1.WriteLocked == l1.WriteLocked
        assert r1.UID == l1.UID
        assert r2 == l2
Exemplo n.º 5
0
    def test_getRange_success_enterprise(self):

        type(self.sedmock).SSC = mock.PropertyMock(return_value='Enterprise')

        # kwrv contains the range object for Enterprise drives
        self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {'ReadLocked': 0, 
                                                            'UID': '\x00\x00\x08\x02\x00\x00\x00\x02', 
                                                            'CommonName': 'Locking', 
                                                            'RangeLength': 64, 
                                                            'ReadLockEnabled': 1, 
                                                            'ActiveKey': '\x00\x00\x08\x06\x00\x00\x00\x02', 
                                                            'WriteLockEnabled': 1, 
                                                            'WriteLocked': 0, 
                                                            'RangeStart': 8, 
                                                            'LockOnReset': [1], 
                                                            '_AllowATAUnlock': 0, 
                                                            'Name': 'Band1'})
                                                  
        r1, r2 = (self.sed.getRange(self.sed.rangeNo,self.sed.auth_SID,authAs=(self.sed.auth_BandMaster, self.sed_dev)))
        x = self.range_convert(kwrv)
        l1 = SedObject(x)
        l2 = True

        assert r1.Name == l1.Name
        assert r1.RangeStart == l1.RangeStart
        assert r1.RangeLength == l1.RangeLength
        assert r1.LockOnReset == l1.LockOnReset
        assert r1.ReadLockEnabled == l1.ReadLockEnabled
        assert r1.RangeStart == l1.RangeStart
        assert r1.WriteLockEnabled == l1.WriteLockEnabled
        assert r1.ReadLocked == l1.ReadLocked
        assert r1.WriteLocked == l1.WriteLocked
        assert r1.UID == l1.UID
        assert r1._AllowATAUnlock == l1._AllowATAUnlock
        assert r2 == l2
Exemplo n.º 6
0
 def test_get_media_encryption_key_success(self):
     
     # kwrv contains the UID in bytes from the drive
     self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {10: b'\x00\x00\x08\x06\x00\x03\x00\x01'}) 
     m1, m2 = self.sed.get_MEK(self.sed.rangeNo, self.sed.auth_Admin, authAs=(self.sed.auth_Admin,self.sed_dev))
     l1 = SedObject(kwrv)
     l2 = True
     print(l1)
Exemplo n.º 7
0
 def test_getPort_table_success_opal(self):
         
     type(self.sedmock).SSC = mock.PropertyMock(return_value='Opalv2')
     # kwrv contains the port table for Opal drives
     self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {0: b'\x00\x01\x00\x02\x00\x01\x00\x02', 1: b'FWDownload', 2: [], 3: 0})
     p = (self.sed.getPort(self.sed.port_No_2, authAs=(self.sed.auth_SID,self.sed.valid_cred)))
     x = self.port_convert(kwrv)
     l = SedObject(x)
     assert p.Name == l.Name
     assert p.PortLocked == l.PortLocked
     assert p.UID == l.UID
Exemplo n.º 8
0
    def test_getPskEntry_success_opal(self):

        type(self.sedmock).SSC = mock.PropertyMock(return_value='Opalv2')
        # kwrv contains the TlsPsk object with values read reflected from the TCG specification
        self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {0: '\x00\x00\x00\x1e\x00\x00\x00\x01', 1: 'TLS_PSK_Key1', 2: '', 3: 0, 5: '\x00\xaa'})
        p = self.sed.getPskEntry(self.sed.psk)
        kwrv = self.psk_convert(kwrv)
        mocked_return = SedObject(kwrv)
        assert p.Enabled == mocked_return.Enabled
        assert p.CommonName == mocked_return.CommonName
        assert p.Name == mocked_return.Name
        assert p.UID == mocked_return.UID
Exemplo n.º 9
0
    def test_getPskEntry_success_enterprise(self):

        # kwrv contains the TlsPsk object with values read reflected from the TCG specification
        self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {b'CipherSuite': b'\x00\xaa', b'CommonName': b'', b'Enabled': 1, b'Name': b'TLS_PSK_Key0', b'UID': b'\x00\x00\x00\x1e\x00\x00\x00\x01'})
        p = self.sed.getPskEntry(self.sed.psk)
        kwrv = self.psk_convert(kwrv)
        mocked_return = SedObject(kwrv)
        assert p.Enabled == mocked_return.Enabled
        assert p.CommonName == mocked_return.CommonName
        assert p.Name == mocked_return.Name
        assert p.UID == mocked_return.UID
        assert p.CipherSuite == mocked_return.CipherSuite
Exemplo n.º 10
0
 def test_getPort_table_success_enterpise_with_LockOnReset(self):
         
     type(self.sedmock).SSC = mock.PropertyMock(return_value='Enterprise')
     # kwrv contains the port table for Enterprise drives
     self.sedmock.invoke.return_value = status, rv, kwrv = (0, [], {b'UID': b'\x00\x01\x00\x02\x00\x01\x00\x03', b'Name': b'UDS', b'LockOnReset': [0], b'PortLocked': 1})
     p = (self.sed.getPort(self.sed.port_No_2, authAs=(self.sed.auth_SID,self.sed.valid_cred)))
     x = self.port_convert(kwrv)
     l = SedObject(x)
     assert p.LockOnReset == l.LockOnReset
     assert p.Name == l.Name
     assert p.PortLocked == l.PortLocked
     assert p.UID == l.UID