Skip to content

Commit 84e8f31

Browse files
committed
Reject host attempts to set keys in reserved ECC slots (117-132)
Host OKSETPRIV requests may only target user slots (RSA 1-4, ECC 101-116). Reserved ECC slots 117-132 (HMAC 129/130, backup 131, derivation 128/132) are provisioned by firmware via direct set_private() calls that bypass this dispatch, so the guard does not affect internal provisioning.
1 parent 0de93a5 commit 84e8f31

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

onlykey/okcore.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,19 @@ void recvmsg(int n)
441441
if (profilemode != NONENCRYPTEDPROFILE)
442442
{
443443
#ifdef STD_VERSION
444-
if (recv_buffer[0] != 0xBA)
444+
if (recv_buffer[0] != 0xBA) {
445+
// A host may only set keys in user slots: RSA 1-4 or ECC
446+
// 101-116. Reserved ECC slots 117-132 hold firmware-managed
447+
// keys (HMAC 129/130, backup 131, derivation 128/132) and are
448+
// provisioned by the firmware itself via direct set_private()
449+
// calls that bypass this host dispatch. Reject host attempts
450+
// to write a reserved slot, for every key type.
451+
if (recv_buffer[5] >= 117 && recv_buffer[5] <= 132) {
452+
hidprint("Error cannot set key in reserved slot (117-132)");
453+
return;
454+
}
445455
set_private(recv_buffer);
456+
}
446457
#endif
447458
}
448459
}

0 commit comments

Comments
 (0)