diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp index 73a8b3c543c11fd8531c346cfb287ddd93f72bcd..1e75ead85be4555c21c234b12647df5d065b9ee7 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp @@ -753,11 +753,43 @@ bool drive::DriveIBM3592::isEncryptionCapEnabled() { cta::exception::Errnum::throwOnMinusOne( m_sysWrapper.ioctl(this->m_tapeFD, SG_IO, &sgh), "Failed SG_IO ioctl in DriveIBM3592::isEncryptionCapEnabled"); - SCSI::ExceptionLauncher(sgh, "SCSI error in DriveIBM3592::clearEncryptionKey"); + SCSI::ExceptionLauncher(sgh, "SCSI error in DriveIBM3592::isEncryptionCapEnabled"); return SCSI::Structures::toU16(pl.supportedProtocolListLength) > 1; } +bool drive::DriveLTO::isEncryptionCapEnabled() { + /* + * Encryption enable support. Initially copied from IBM enterprise implementation. + */ + /* + * We are acquiring the encryption capability from the length of the SPIN index page. + * If it has one page (only 0x00), then encryption is disabled from the libary. + * If it has more pages, the encryption(0x00, 0x20 at the moment of writing), then it is enabled. + */ + SCSI::Structures::LinuxSGIO_t sgh; + SCSI::Structures::encryption::spinCDB_t cdb; + SCSI::Structures::senseData_t<255> senseBuff; + SCSI::Structures::encryption::spinPageList_t<20> pl; + + cdb.securityProtocol = SCSI::encryption::spinSecurityProtocolPages::securityProtocolInformation; + SCSI::Structures::setU16(cdb.securityProtocolSpecific, 0x0000); + SCSI::Structures::setU32(cdb.allocationLength, sizeof(pl)); + + sgh.setCDB(&cdb); + sgh.setDataBuffer(&pl); + sgh.setSenseBuffer(&senseBuff); + sgh.dxfer_direction = SG_DXFER_FROM_DEV; + + castor::exception::Errnum::throwOnMinusOne( + m_sysWrapper.ioctl(this->m_tapeFD, SG_IO, &sgh), + "Failed SG_IO ioctl in DriveLTO::isEncryptionCapEnabled"); + SCSI::ExceptionLauncher(sgh, "SCSI error in DriveLTO::isEncryptionCapEnabled"); + + return SCSI::Structures::toU16(pl.supportedProtocolListLength) > 1; +} + + bool drive::DriveT10000::isEncryptionCapEnabled() { /* * We are acquiring the encryption capability from the inquiry page on Oracle T10k drives diff --git a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp index 575ea21c3b9edbd91de9490cd5313929f302243f..d22d1f8b15a0733db50f95bee948ee6cf23002f0 100644 --- a/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp +++ b/tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp @@ -589,6 +589,7 @@ namespace drive { virtual compressionStats getCompression(); virtual void clearCompressionStats(); virtual std::vector<castor::tape::tapeserver::drive::endOfWrapPosition> getEndOfWrapPositions(); + virtual bool isEncryptionCapEnabled(); }; class DriveIBM3592 : public DriveGeneric {