Hsmauth

From 0dayInc/pwn · View interactive version

Hsmauth is an AI agent skill from the GitHub repository 0dayInc/pwn. Manage native HSM Auth credentials and sessions.

How to use this skill

Skill file

Native YubiHSM Auth

When to use

Use PWN::Plugins::YubiKey::HSMAuth for YubiKey YubiHSM Auth credentials and

session-key derivation. This is not the YubiHSM2 management protocol or a browser

WebAuthn ceremony. The root YubiKey router owns transport lifetime.

Public API

generate, import, export, symmetric, derive, delete, change-password,

and access change-management-key / change-management-password.

returns the host challenge or ephemeral uncompressed P-256 public point.

card_crypto:, public_key:, confirm: true)` returns a Hash containing exactly

key_senc, key_smac, key_srmac, each sixteen raw bytes.

Procedure

  1. Select the intended APDU connection; never guess a device or factory key.
  2. Read .help. Supply passwords/keys only in memory or through a

secret_provider: receiving a field Symbol after literal confirm: true.

Wrong authentication is attempted once; APDU errors preserve status without

logging payloads. Status 63Cx encodes remaining attempts in its low nibble.

  1. Use exact complete label bytes. Management changes do not substring-match.
  2. Symmetric import uses raw key_enc: and key_mac: (sixteen bytes each).

derive uses derivation_password: with PBKDF2-HMAC-SHA256, salt Yubico,

10,000 iterations. generate creates a P-256 private key on device; symmetric

--generate returns the generated keys in memory for explicit caller storage.

  1. Asymmetric import accepts private_key: as a raw 32-byte scalar, an in-memory

PEM/DER String or private OpenSSL EC object on prime256v1. Encrypted PEM/DER

takes key_password:; it never prompts implicitly or retries decryption.

Export returns public key bytes in RAW, PEM (default) or DER format;

filenames and secret argv are not accepted by the family API.

  1. For a live HSM challenge exchange, retain the same open_session handle for

challenge and calculate. Do not select another application between them.

Symmetric context is host challenge + card challenge (sixteen bytes), optional

card cryptogram eight bytes. Asymmetric context is two uncompressed P-256

points (130 bytes), public_key: is the HSM long-term public point, and

card_crypto: contains sixteen bytes. The caller manages the HSM side.

  1. Check the returned verification scope. Create/delete/reset verify inventory

metadata, not private key contents. Password and management-key writes return

status: :acknowledged, verification: :not_readable; no second authentication

attempt is made merely to simulate readback.

Pitfalls

lookup is performed. Raw keys are not auto-decoded from hexadecimal Strings.

per protocol. An explicitly supplied empty String is allowed, but nil never

means the factory credential. Ruby memory is not guaranteed zeroizable.

credential-password changes require 5.8.0. Random management-key generation is

rejected on 5.8 or later. SELECT failure is not permission to fall back.

Verification

Run bundle exec rspec spec/lib/pwn/plugins/yubikey/hsmauth_spec.rb and scoped

RuboCop. The specs exercise production Protocol APDUs with a fake raw exchange

boundary and independent PBKDF2 / P-256 wire vectors. No hardware interoperability

or secure-channel transport is claimed by these offline tests.

References: pinned yubikey-manager 5.9.1 yubikit/hsmauth.py and

ykman/_cli/hsmauth.py; https://developers.yubico.com/yubihsm-auth/ .

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.