14#define OPAL_MSID_LENGTH 128
34 UINT32 RemovalTimeOut;
40 DEBUG ((DEBUG_INFO,
"OpalUtilPsidRevert: Timeout value = %d\n", RemovalTimeOut));
48 OPAL_ADMIN_SP_PSID_AUTHORITY,
51 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
53 if (Ret != TcgResultSuccess) {
61 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
62 Ret = TcgResultFailure;
84 const VOID *GeneratedSid,
94 NULL_CHECK (GeneratedSid);
95 NULL_CHECK (Password);
103 OPAL_ADMIN_SP_SID_AUTHORITY,
106 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
107 DEBUG ((DEBUG_INFO,
"start session with admin SP as SID authority failed: Ret=%d MethodStatus=%u\n", Ret, MethodStatus));
116 OPAL_UID_ADMIN_SP_C_PIN_SID,
122 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
124 DEBUG ((DEBUG_INFO,
"set Password failed: Ret=%d MethodStatus=%u\n", Ret, MethodStatus));
133 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
134 DEBUG ((DEBUG_INFO,
"activate locking SP failed: Ret=%d MethodStatus=%u\n", Ret, MethodStatus));
139 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
140 Ret = TcgResultFailure;
167 const VOID *Password,
172 BOOLEAN ReadLockEnabled,
173 BOOLEAN WriteLockEnabled,
181 NULL_CHECK (Session);
182 NULL_CHECK (Password);
193 OPAL_LOCKING_SP_ADMIN1_AUTHORITY,
196 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
197 DEBUG ((DEBUG_INFO,
"start session with locking SP failed: Ret=%d MethodStatus=%u\n", Ret, MethodStatus));
217 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
218 DEBUG ((DEBUG_INFO,
"set locking range failed: Ret=%d MethodStatus=0x%x\n", Ret, MethodStatus));
222 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
223 Ret = TcgResultFailure;
245 const VOID *OldPassword,
246 UINT32 OldPasswordLength,
247 const VOID *NewPassword,
248 UINT32 NewPasswordLength
254 NULL_CHECK (Session);
255 NULL_CHECK (OldPassword);
256 NULL_CHECK (NewPassword);
267 OPAL_ADMIN_SP_SID_AUTHORITY,
270 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
271 DEBUG ((DEBUG_INFO,
"start session with admin SP using old Password failed\n"));
278 Ret =
OpalSetPassword (Session, OPAL_UID_ADMIN_SP_C_PIN_SID, NewPassword, NewPasswordLength, &MethodStatus);
280 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
281 DEBUG ((DEBUG_INFO,
"set new admin SP Password failed\n"));
291 OPAL_LOCKING_SP_ADMIN1_AUTHORITY,
294 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
295 DEBUG ((DEBUG_INFO,
"start session with locking SP using old Password failed\n"));
302 Ret =
OpalSetPassword (Session, OPAL_LOCKING_SP_C_PIN_ADMIN1, NewPassword, NewPasswordLength, &MethodStatus);
304 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
305 DEBUG ((DEBUG_INFO,
"set new locking SP Password failed\n"));
310 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
311 Ret = TcgResultFailure;
332 const VOID *OldPassword,
333 UINT32 OldPasswordLength,
334 const VOID *NewPassword,
335 UINT32 NewPasswordLength
341 NULL_CHECK (Session);
342 NULL_CHECK (OldPassword);
343 NULL_CHECK (NewPassword);
354 OPAL_LOCKING_SP_USER1_AUTHORITY,
357 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
360 OPAL_LOCKING_SP_C_PIN_USER1,
366 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
384 OPAL_LOCKING_SP_ADMIN1_AUTHORITY,
387 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
388 DEBUG ((DEBUG_INFO,
"StartSession with locking SP as admin1 authority failed\n"));
397 OPAL_LOCKING_SP_C_PIN_USER1,
398 OPAL_LOCKING_SP_USER1_AUTHORITY,
404 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
405 DEBUG ((DEBUG_INFO,
"OpalSetLockingSpAuthorityEnabledAndPin failed\n"));
410 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
411 Ret = TcgResultFailure;
430 const VOID *Password,
431 UINT32 PasswordLength,
438 NULL_CHECK (Session);
439 NULL_CHECK (Password);
447 HostSigningAuthority,
450 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
452 return TcgResultSuccess;
455 return TcgResultFailure;
472 const VOID *Password,
473 UINT32 PasswordLength,
474 BOOLEAN *PasswordFailed
480 NULL_CHECK (Session);
481 NULL_CHECK (Password);
482 NULL_CHECK (PasswordFailed);
493 OPAL_LOCKING_SP_ADMIN1_AUTHORITY,
497 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
499 *PasswordFailed =
FALSE;
511 OPAL_LOCKING_SP_USER1_AUTHORITY,
515 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
517 *PasswordFailed =
FALSE;
520 *PasswordFailed =
TRUE;
524 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
525 Ret = TcgResultFailure;
544 const VOID *Password,
545 UINT32 PasswordLength,
546 BOOLEAN *PasswordFailed
552 NULL_CHECK (Session);
553 NULL_CHECK (Password);
554 NULL_CHECK (PasswordFailed);
565 OPAL_LOCKING_SP_ADMIN1_AUTHORITY,
568 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
569 DEBUG ((DEBUG_INFO,
"StartSession with Locking SP as Admin1 failed\n"));
570 *PasswordFailed =
TRUE;
574 *PasswordFailed =
FALSE;
579 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
580 Ret = TcgResultFailure;
602 BOOLEAN KeepUserData,
603 const VOID *Password,
604 UINT32 PasswordLength,
605 BOOLEAN *PasswordFailed,
612 UINT32 RemovalTimeOut;
614 NULL_CHECK (Session);
616 NULL_CHECK (Password);
617 NULL_CHECK (PasswordFailed);
620 DEBUG ((DEBUG_INFO,
"OpalUtilRevert: Timeout value = %d\n", RemovalTimeOut));
628 OPAL_LOCKING_SP_ADMIN1_AUTHORITY,
632 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
633 DEBUG ((DEBUG_INFO,
"error starting session: Ret=%d, MethodStatus=%u\n", Ret, MethodStatus));
634 *PasswordFailed =
TRUE;
638 *PasswordFailed =
FALSE;
643 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
647 DEBUG ((DEBUG_INFO,
"OpalAdminRevert as admin failed\n"));
654 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
655 Ret = TcgResultFailure;
675 const VOID *Password,
676 UINT32 PasswordLength,
684 NULL_CHECK (Session);
686 NULL_CHECK (Password);
697 OPAL_ADMIN_SP_SID_AUTHORITY,
700 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
707 Ret =
OpalSetPassword (Session, OPAL_UID_ADMIN_SP_C_PIN_SID, Msid, MsidLength, &MethodStatus);
711 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
712 Ret = TcgResultFailure;
732 const VOID *Password,
733 UINT32 PasswordLength,
741 NULL_CHECK (Session);
742 NULL_CHECK (Password);
753 OPAL_LOCKING_SP_ADMIN1_AUTHORITY,
756 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
764 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
769 if (MethodStatus == TCG_METHOD_STATUS_CODE_AUTHORITY_LOCKED_OUT) {
770 DEBUG ((DEBUG_INFO,
"unlock as admin failed with AUTHORITY_LOCKED_OUT\n"));
782 OPAL_LOCKING_SP_USER1_AUTHORITY,
785 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
786 DEBUG ((DEBUG_INFO,
"StartSession with Locking SP as User1 failed\n"));
794 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
795 if (MethodStatus == TCG_METHOD_STATUS_CODE_AUTHORITY_LOCKED_OUT) {
800 Ret = TcgResultFailureInvalidType;
802 Ret = TcgResultFailure;
823 UINT32 MsidBufferLength,
830 NULL_CHECK (Session);
832 NULL_CHECK (MsidLength);
843 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
844 Ret =
OpalGetMsid (Session, MsidBufferLength, Msid, MsidLength);
848 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
849 Ret = TcgResultFailure;
877 OPAL_OWNER_SHIP Owner;
879 if ((Session ==
NULL) || (Msid ==
NULL)) {
880 return OpalOwnershipUnknown;
883 Owner = OpalOwnershipUnknown;
893 OPAL_ADMIN_SP_SID_AUTHORITY,
896 if ((Ret == TcgResultSuccess) && (MethodStatus == TCG_METHOD_STATUS_CODE_SUCCESS)) {
900 Owner = OpalOwnershipNobody;
926 NULL_CHECK (LockingFeature);
936 return (OwnerShip == OpalOwnershipUnknown && LockingFeature->LockingEnabled);
952 const VOID *GeneratedSid,
954 UINT8 *ActiveDataRemovalMechanism
960 NULL_CHECK (Session);
961 NULL_CHECK (GeneratedSid);
962 NULL_CHECK (ActiveDataRemovalMechanism);
970 OPAL_ADMIN_SP_ANYBODY_AUTHORITY,
973 if ((Ret != TcgResultSuccess) || (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS)) {
974 DEBUG ((DEBUG_INFO,
"Start session with admin SP as SID authority failed: Ret=%d MethodStatus=%u\n", Ret, MethodStatus));
975 if (MethodStatus != TCG_METHOD_STATUS_CODE_SUCCESS) {
976 Ret = TcgResultFailure;
984 ActiveDataRemovalMechanism
987 if (Ret != TcgResultSuccess) {
988 DEBUG ((DEBUG_INFO,
"Pyrite2 Get Active Data Removal Mechanism failed: Ret=%d\n", Ret));
1005 IN BOOLEAN IsMinute,
1010 return Time * 2 * 60;
1030 case OverwriteDataErase:
1042 case ResetWritePointers:
1045 case VendorSpecificErase:
1064 OUT UINT32 *RemovalMechanismLists
1073 NULL_CHECK (Session);
1074 NULL_CHECK (RemovalMechanismLists);
1076 DataSize =
sizeof (Descriptor);
1078 if (Ret != TcgResultSuccess) {
1079 return TcgResultFailure;
1082 ASSERT (Descriptor.RemovalMechanism != 0);
1084 for (Index = 0; Index < ResearvedMechanism; Index++) {
1085 BitValue = (BOOLEAN)
BitFieldRead8 (Descriptor.RemovalMechanism, Index, Index);
1087 if (BitValue == 0) {
1088 RemovalMechanismLists[Index] = 0;
1094 return TcgResultSuccess;
1112 UINT8 Msid[OPAL_MSID_LENGTH];
1113 UINT32 RemovalMechanishLists[ResearvedMechanism];
1114 UINT8 ActiveDataRemovalMechanism;
1117 if ((TcgResult != TcgResultSuccess) || (SupportedAttributes.DataRemoval == 0)) {
1121 TcgResult =
OpalUtilGetMsid (Session, Msid, OPAL_MSID_LENGTH, &MsidLength);
1122 if (TcgResult != TcgResultSuccess) {
1127 if (TcgResult != TcgResultSuccess) {
1132 if (TcgResult != TcgResultSuccess) {
1136 return RemovalMechanishLists[ActiveDataRemovalMechanism];
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
UINT8 EFIAPI BitFieldRead8(IN UINT8 Operand, IN UINTN StartBit, IN UINTN EndBit)
#define DEBUG(Expression)
UINT64 TCG_UID
UID in host native byte order.
TCG_RESULT OpalPyrite2GetActiveDataRemovalMechanism(IN OPAL_SESSION *AdminSpSession, OUT UINT8 *ActiveDataRemovalMechanism)
TCG_RESULT OpalPyrite2AdminRevert(OPAL_SESSION *LockingSpSession, BOOLEAN KeepUserData, UINT8 *MethodStatus, UINT32 EstimateTimeCost)
TCG_RESULT OpalGetFeatureDescriptor(IN OPAL_SESSION *Session, IN UINT16 FeatureCode, IN OUT UINTN *DataSize, OUT VOID *Data)
TCG_RESULT OpalPyrite2PsidRevert(OPAL_SESSION *AdminSpSession, UINT32 EstimateTimeCost)
TCG_RESULT EFIAPI OpalGetSupportedAttributesInfo(OPAL_SESSION *Session, OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes, UINT16 *OpalBaseComId)
TCG_RESULT EFIAPI OpalSetPassword(OPAL_SESSION *Session, TCG_UID CpinRowUid, const VOID *NewPin, UINT32 NewPinLength, UINT8 *MethodStatus)
TCG_RESULT EFIAPI OpalSetLockingSpAuthorityEnabledAndPin(OPAL_SESSION *LockingSpSession, TCG_UID CpinRowUid, TCG_UID AuthorityUid, const VOID *NewPin, UINT32 NewPinLength, UINT8 *MethodStatus)
TCG_RESULT EFIAPI OpalEndSession(OPAL_SESSION *Session)
TCG_RESULT EFIAPI OpalSetLockingRange(OPAL_SESSION *LockingSpSession, TCG_UID LockingRangeUid, UINT64 RangeStart, UINT64 RangeLength, BOOLEAN ReadLockEnabled, BOOLEAN WriteLockEnabled, BOOLEAN ReadLocked, BOOLEAN WriteLocked, UINT8 *MethodStatus)
TCG_RESULT EFIAPI OpalStartSession(OPAL_SESSION *Session, TCG_UID SpId, BOOLEAN Write, UINT32 HostChallengeLength, const VOID *HostChallenge, TCG_UID HostSigningAuthority, UINT8 *MethodStatus)
TCG_RESULT EFIAPI OpalGetMsid(OPAL_SESSION *AdminSpSession, UINT32 MsidBufferSize, UINT8 *Msid, UINT32 *MsidLength)
TCG_RESULT EFIAPI OpalActivateLockingSp(OPAL_SESSION *AdminSpSession, UINT8 *MethodStatus)
TCG_RESULT EFIAPI OpalDisableUser(OPAL_SESSION *LockingSpSession, UINT8 *MethodStatus)
TCG_RESULT EFIAPI OpalGlobalLockingRangeGenKey(OPAL_SESSION *LockingSpSession, UINT8 *MethodStatus)
TCG_RESULT EFIAPI OpalUpdateGlobalLockingRange(OPAL_SESSION *LockingSpSession, BOOLEAN ReadLocked, BOOLEAN WriteLocked, UINT8 *MethodStatus)
TCG_RESULT EFIAPI OpalUtilUpdateGlobalLockingRange(OPAL_SESSION *Session, const VOID *Password, UINT32 PasswordLength, BOOLEAN ReadLocked, BOOLEAN WriteLocked)
TCG_RESULT EFIAPI OpalUtilSetOpalLockingRange(OPAL_SESSION *Session, const VOID *Password, UINT32 PassLength, TCG_UID LockingRangeUid, UINT64 RangeStart, UINT64 RangeLength, BOOLEAN ReadLockEnabled, BOOLEAN WriteLockEnabled, BOOLEAN ReadLocked, BOOLEAN WriteLocked)
UINT32 GetDataRemovalTime(IN UINT8 Index, IN DATA_REMOVAL_FEATURE_DESCRIPTOR *Descriptor)
TCG_RESULT EFIAPI OpalUtilGetActiveDataRemovalMechanism(OPAL_SESSION *Session, const VOID *GeneratedSid, UINT32 SidLength, UINT8 *ActiveDataRemovalMechanism)
TCG_RESULT EFIAPI OpalUtilSecureErase(OPAL_SESSION *Session, const VOID *Password, UINT32 PasswordLength, BOOLEAN *PasswordFailed)
TCG_RESULT EFIAPI OpalUtilPsidRevert(OPAL_SESSION *Session, const VOID *Psid, UINT32 PsidLength)
TCG_RESULT EFIAPI OpalUtilRevert(OPAL_SESSION *Session, BOOLEAN KeepUserData, const VOID *Password, UINT32 PasswordLength, BOOLEAN *PasswordFailed, UINT8 *Msid, UINT32 MsidLength)
TCG_RESULT EFIAPI OpalUtilDisableUser(OPAL_SESSION *Session, const VOID *Password, UINT32 PasswordLength, BOOLEAN *PasswordFailed)
TCG_RESULT EFIAPI OpalUtilSetUserPassword(OPAL_SESSION *Session, const VOID *OldPassword, UINT32 OldPasswordLength, const VOID *NewPassword, UINT32 NewPasswordLength)
TCG_RESULT EFIAPI OpalUtilVerifyPassword(OPAL_SESSION *Session, const VOID *Password, UINT32 PasswordLength, TCG_UID HostSigningAuthority)
TCG_RESULT EFIAPI OpalUtilSetSIDtoMSID(OPAL_SESSION *Session, const VOID *Password, UINT32 PasswordLength, UINT8 *Msid, UINT32 MsidLength)
UINT32 CalculateDataRemovalTime(IN BOOLEAN IsMinute, IN UINT16 Time)
BOOLEAN EFIAPI OpalUtilAdminPasswordExists(IN UINT16 OwnerShip, IN TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature)
OPAL_OWNER_SHIP EFIAPI OpalUtilDetermineOwnership(OPAL_SESSION *Session, UINT8 *Msid, UINT32 MsidLength)
TCG_RESULT EFIAPI OpalUtilGetDataRemovalMechanismLists(IN OPAL_SESSION *Session, OUT UINT32 *RemovalMechanismLists)
TCG_RESULT EFIAPI OpalUtilSetAdminPasswordAsSid(OPAL_SESSION *Session, const VOID *GeneratedSid, UINT32 SidLength, const VOID *Password, UINT32 PassLength)
TCG_RESULT EFIAPI OpalUtilSetAdminPassword(OPAL_SESSION *Session, const VOID *OldPassword, UINT32 OldPasswordLength, const VOID *NewPassword, UINT32 NewPasswordLength)
UINT32 GetRevertTimeOut(IN OPAL_SESSION *Session)
TCG_RESULT EFIAPI OpalUtilGetMsid(OPAL_SESSION *Session, UINT8 *Msid, UINT32 MsidBufferLength, UINT32 *MsidLength)