Skip to content

Commit

Permalink
Change FipsStatus to FIPS_STATUS for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
elibon99 committed Aug 16, 2024
1 parent 21c2407 commit 16bff40
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions tests/device/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from yubihsm.core import MAX_MSG_SIZE
from yubihsm.defs import ALGORITHM, CAPABILITY, OBJECT, COMMAND, ORIGIN, FipsStatus
from yubihsm.defs import ALGORITHM, CAPABILITY, OBJECT, COMMAND, ORIGIN, FIPS_STATUS
from yubihsm.objects import (
YhsmObject,
AsymmetricKey,
Expand Down Expand Up @@ -204,12 +204,12 @@ def session2(self, session, connect_hsm):
pytest.skip("Non-FIPS YubiHSM")

def test_set_in_fips_mode(self, session2, info):
assert session2.get_fips_status() == FipsStatus.OFF
assert session2.get_fips_status() == FIPS_STATUS.OFF
session2.set_fips_mode(True)
if info.version < (2, 4, 0):
assert session2.get_fips_status() == FipsStatus.ON
assert session2.get_fips_status() == FIPS_STATUS.ON
else:
assert session2.get_fips_status() == FipsStatus.PENDING
assert session2.get_fips_status() == FIPS_STATUS.PENDING

def test_fips_mode_disables_algorithms(self, session2, info):
session2.set_fips_mode(True)
Expand Down Expand Up @@ -246,7 +246,7 @@ def test_enabling_algorithms_in_fips_mode(self, session2, info):
ALGORITHM.RSA_PKCS1_SHA1: True,
}
)
assert session2.get_fips_mode() == FipsStatus.OFF
assert session2.get_fips_status() == FIPS_STATUS.OFF
else:
with pytest.raises(YubiHsmDeviceError):
session2.set_enabled_algorithms({ALGORITHM.RSA_PKCS1_SHA1: True})
6 changes: 3 additions & 3 deletions yubihsm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
OPTION,
AUDIT,
ERROR,
FipsStatus,
FIPS_STATUS,
)
from .backends import get_backend, YhsmBackend
from .objects import YhsmObject, _label_pack, LABEL_LENGTH
Expand Down Expand Up @@ -986,14 +986,14 @@ def set_fips_mode(self, mode: bool) -> None:
"""
self.put_option(OPTION.FIPS_MODE, struct.pack("!B", mode))

def get_fips_status(self) -> FipsStatus:
def get_fips_status(self) -> FIPS_STATUS:
"""Get the current FIPS status.
YubiHSM2 FIPS only.
:return: The FipsStatus value.
"""
return FipsStatus(self.get_option(OPTION.FIPS_MODE)[0])
return FIPS_STATUS(self.get_option(OPTION.FIPS_MODE)[0])

def get_fips_mode(self) -> bool:
"""Get the current setting for FIPS mode.
Expand Down
2 changes: 1 addition & 1 deletion yubihsm/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class AUDIT(IntEnum):


@unique
class FipsStatus(IntEnum):
class FIPS_STATUS(IntEnum):
"""Values for FIPS status"""

OFF = 0x00
Expand Down

0 comments on commit 16bff40

Please sign in to comment.