Craton HSM

Craton HSM — Kreya gRPC Manual Tests

Setup

1. Install Kreya

Download from kreya.app (Windows, macOS, Linux).

2. Open the Project

Open kreya/Craton HSM-gRPC.krproj in Kreya. The proto file is imported automatically from craton-hsm-daemon/proto/craton_hsm.proto.

3. Select Environment

Two environments are provided:

EnvironmentEndpointUse case
defaulthttp://localhost:9898Local development
remotehttp://185.177.116.16:9898Remote test server

Select the environment in the Kreya environment dropdown before running tests.

4. Update Variables

After running 02-OpenSession, copy the session_handle from the response and update the session_handle variable in the active environment. All subsequent requests reference {{session_handle}}.


PIN Reference

RolePlaintextBase64 (in requests)
SOSoP1n!Fips#2024U29QMW4hRmlwcyMyMDI0
UserUsrP1n!Fips#2024VXNyUDFuIUZpcHMjMjAyNA==

Tests — Run In Order

01-InitToken

Initialize the token with SO PIN and label.

FieldValue
Methodcraton_hsm.HsmService/InitToken
Expected{} (empty = success)

02-OpenSession

Open a read-write session on slot 0.

FieldValue
Methodcraton_hsm.HsmService/OpenSession
Expected{ "sessionHandle": "<number>" }

Copy the sessionHandle value and update the session_handle environment variable.

03-LoginSO

Log in as Security Officer.

FieldValue
Methodcraton_hsm.HsmService/Login
user_type0 (SO)
Expected{}

04-GetTokenInfo

Query token metadata.

FieldValue
Methodcraton_hsm.HsmService/GetTokenInfo
ExpectedJSON with label, initialized: true, loginState, sessionCount

05-GenerateRandom

Generate 32 random bytes via HMAC_DRBG.

FieldValue
Methodcraton_hsm.HsmService/GenerateRandom
length32
Expected{ "randomData": "<base64>" }

06-DigestSHA256

SHA-256 digest of "Hello Craton HSM".

FieldValue
Methodcraton_hsm.HsmService/Digest
mechanism_type592 (0x250 = CKM_SHA256)
dataSGVsbG8gQ3JhdG9uIEhTTQ== (base64 of "Hello Craton HSM")
Expected{ "digest": "<base64 32-byte hash>" }

Verify: echo -n 'Hello Craton HSM' | sha256sum

07-DigestSHA512

SHA-512 digest of "Hello Craton HSM".

FieldValue
Methodcraton_hsm.HsmService/Digest
mechanism_type608 (0x260 = CKM_SHA512)
Expected{ "digest": "<base64 64-byte hash>" }

08-FindObjects

List all objects (empty on fresh token).

FieldValue
Methodcraton_hsm.HsmService/FindObjects
Expected (fresh token){ "objectHandles": [] }

09-GenerateKey (AES)

Attempt AES key generation.

FieldValue
Methodcraton_hsm.HsmService/GenerateKey
mechanism_type4224 (0x1080 = CKM_AES_KEY_GEN)
ExpectedgRPC error (template requirements)

10-Sign (RSA)

Attempt RSA signing (requires key to exist).

FieldValue
Methodcraton_hsm.HsmService/Sign
mechanism_type1 (CKM_RSA_PKCS)
ExpectedgRPC error (no key)

Error Case Tests

11-BadSessionHandle

Use an invalid session handle.

FieldValue
Methodcraton_hsm.HsmService/GenerateRandom
session_handle999999
ExpectedgRPC error (session not found)

12-WrongPIN

Attempt login with incorrect PIN.

FieldValue
Methodcraton_hsm.HsmService/Login
pind3JvbmdwaW4= (base64 of "wrongpin")
ExpectedgRPC error (PIN invalid)

After 5 failed attempts, the account enters a cooldown lockout.

13-ExceedMaxRandom

Request more random bytes than the limit allows.

FieldValue
Methodcraton_hsm.HsmService/GenerateRandom
length99999999
ExpectedgRPC error (exceeds 1 MiB limit)

Cleanup

14-Logout

Methodcraton_hsm.HsmService/Logout
Expected{}

15-CloseSession

Methodcraton_hsm.HsmService/CloseSession
Expected{}

16-UseClosedSession (should fail)

Attempt to use the closed session handle.

Methodcraton_hsm.HsmService/GenerateRandom
ExpectedgRPC error (session not found)

Project Structure

kreya/
  Craton HSM-gRPC.krproj          # Kreya project file (open this)
  directory.krpref              # Default gRPC endpoint config
  default.krenv                 # Local environment (localhost:9898)
  remote.krenv                  # Remote test server environment
  craton_hsm/HsmService/
    01-InitToken/               # Each test is a directory with:
      InitToken.krop            #   - Operation definition (.krop)
      InitToken-request.json    #   - Request payload (.json)
    02-OpenSession/
    03-LoginSO/
    ...
    16-UseClosedSession/

Mechanism Type Reference

ConstantHexDecimalAlgorithm
CKM_RSA_PKCS0x00011RSA PKCS#1 v1.5
CKM_SHA2560x0250592SHA-256 digest
CKM_SHA5120x0260608SHA-512 digest
CKM_AES_KEY_GEN0x10804224AES key generation
CKM_AES_GCM0x10874231AES-GCM encrypt/decrypt
CKM_ECDSA0x10414161ECDSA sign/verify
CKM_EDDSA0x10574183EdDSA sign/verify

See API Reference for the full mechanism list.