From 48e310c33fa1fbdb98062b6abbed45ad100f3ae6 Mon Sep 17 00:00:00 2001 From: Tharsan Ponnampalam Date: Tue, 16 Jul 2019 16:04:39 -0400 Subject: [PATCH] lib: Implemented change pin for the puk key --- ykcs11/yubico_token.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ykcs11/yubico_token.c b/ykcs11/yubico_token.c index 08040e6..2cbc3dc 100644 --- a/ykcs11/yubico_token.c +++ b/ykcs11/yubico_token.c @@ -381,7 +381,13 @@ CK_RV YUBICO_token_change_pin(ykpiv_state *state, CK_USER_TYPE user_type, CK_UTF break; } case CKU_USER: - res = ykpiv_change_pin(state, (const char*)pOldPin, ulOldLen, (const char*)pNewPin, ulNewLen, &tries); + if(ulOldLen >= 4 && strncmp((const char*)pOldPin, "puk:", 4) == 0){ + DBG("Changing PUK pin") + res = ykpiv_change_puk(state, (const char*)pOldPin + 4, ulOldLen - 4, (const char*)pNewPin, ulNewLen, &tries); + }else{ + DBG("Changing USER pin") + res = ykpiv_change_pin(state, (const char*)pOldPin, ulOldLen, (const char*)pNewPin, ulNewLen, &tries); + } break; default: DBG("TODO implement other context specific pin change");