protected void ValidateKeySchemeAndLength(KeyTypeTable.KeyFunction func, LMKPairs.LMKPair Pair, string var) { KeyTypeTable.AuthorizedStateRequirement requirement = KeyTypeTable.GetAuthorizedStateRequirement(KeyTypeTable.KeyFunction.Generate, Pair, var); if (requirement == KeyTypeTable.AuthorizedStateRequirement.NotAllowed) { throw new Exceptions.XFunctionNotPermitted("FUNCTION NOT PERMITTED"); } else if ((requirement == KeyTypeTable.AuthorizedStateRequirement.NeedsAuthorizedState) && (Convert.ToBoolean(Resources.GetResource(Resources.AUTHORIZED_STATE)) == false)) { throw new Exceptions.XNeedsAuthorizedState("NOT AUTHORIZED"); } }
protected bool ValidateFunctionRequirement(KeyTypeTable.KeyFunction func, LMKPairs.LMKPair Pair, string var, ThalesCore.Message.MessageResponse MR) { KeyTypeTable.AuthorizedStateRequirement requirement = KeyTypeTable.GetAuthorizedStateRequirement(KeyTypeTable.KeyFunction.Generate, Pair, var); if (requirement == KeyTypeTable.AuthorizedStateRequirement.NotAllowed) { MR.AddElement(ErrorCodes.ER_29_FUNCTION_NOT_PERMITTED); return(false); } else if ((requirement == KeyTypeTable.AuthorizedStateRequirement.NeedsAuthorizedState) && (Convert.ToBoolean(Resources.GetResource(Resources.AUTHORIZED_STATE)) == false)) { MR.AddElement(ErrorCodes.ER_17_HSM_IS_NOT_IN_THE_AUTHORIZED_STATE); return(false); } else { return(true); } }