int pin_function(void *userdata, int attempt, const char *token_url, const char *token_label, unsigned flags, char *pin, size_t pin_max) { if (flags & GNUTLS_PIN_FINAL_TRY) printf("This is the final try before locking!\n"); if (flags & GNUTLS_PIN_COUNT_LOW) printf("Only few tries left before locking!\n"); if (flags & GNUTLS_PIN_WRONG) printf("Wrong PIN has been provided in the previous attempt\n"); /* userdata is the second value passed to gnutls_pkcs11_set_pin_function() * in this example we passed the PIN as a null terminated value. */ snprintf(pin, pin_max, "%s", (char*)userdata); return 0; }