diff --git a/tests/pico-fido/test_authenticate.py b/tests/pico-fido/test_authenticate.py
index e466706..6223305 100644
--- a/tests/pico-fido/test_authenticate.py
+++ b/tests/pico-fido/test_authenticate.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
from fido2.utils import sha256
from fido2.client import CtapError
import pytest
diff --git a/tests/pico-fido/test_blob.py b/tests/pico-fido/test_blob.py
index d7faf2d..f5d2a73 100644
--- a/tests/pico-fido/test_blob.py
+++ b/tests/pico-fido/test_blob.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import pytest
from fido2.ctap import CtapError
from fido2.ctap2.pin import PinProtocolV2, ClientPin
diff --git a/tests/pico-fido/test_cred_mgmt.py b/tests/pico-fido/test_cred_mgmt.py
index dd201cd..6434e0a 100644
--- a/tests/pico-fido/test_cred_mgmt.py
+++ b/tests/pico-fido/test_cred_mgmt.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import pytest
import time
import random
diff --git a/tests/pico-fido/test_credprotect.py b/tests/pico-fido/test_credprotect.py
index c7403c6..a775082 100644
--- a/tests/pico-fido/test_credprotect.py
+++ b/tests/pico-fido/test_credprotect.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import pytest
from fido2.ctap2.extensions import CredProtectExtension
from fido2.webauthn import UserVerificationRequirement
diff --git a/tests/pico-fido/test_ctap1_interop.py b/tests/pico-fido/test_ctap1_interop.py
index af1b602..da7e244 100644
--- a/tests/pico-fido/test_ctap1_interop.py
+++ b/tests/pico-fido/test_ctap1_interop.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
# Test U2F register works with FIDO2 auth
def test_ctap1_register(RegRes):
pass
diff --git a/tests/pico-fido/test_discoverable.py b/tests/pico-fido/test_discoverable.py
index 93edc46..776ba41 100644
--- a/tests/pico-fido/test_discoverable.py
+++ b/tests/pico-fido/test_discoverable.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
from fido2.client import CtapError
import pytest
import random
diff --git a/tests/pico-fido/test_getinfo.py b/tests/pico-fido/test_getinfo.py
index 8a4a8be..e78f330 100644
--- a/tests/pico-fido/test_getinfo.py
+++ b/tests/pico-fido/test_getinfo.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import pytest
from fido2.client import CtapError
diff --git a/tests/pico-fido/test_hid.py b/tests/pico-fido/test_hid.py
index a75bffc..345440c 100644
--- a/tests/pico-fido/test_hid.py
+++ b/tests/pico-fido/test_hid.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import os
import socket
import time
diff --git a/tests/pico-fido/test_hmac_secret.py b/tests/pico-fido/test_hmac_secret.py
index 11834aa..8a2d619 100644
--- a/tests/pico-fido/test_hmac_secret.py
+++ b/tests/pico-fido/test_hmac_secret.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import pytest
from fido2.ctap import CtapError
from fido2.ctap2.extensions import HmacSecretExtension
diff --git a/tests/pico-fido/test_minpinlength.py b/tests/pico-fido/test_minpinlength.py
index 6b4efd9..5472c82 100644
--- a/tests/pico-fido/test_minpinlength.py
+++ b/tests/pico-fido/test_minpinlength.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import pytest
from fido2.ctap2.extensions import CredProtectExtension
from fido2.webauthn import UserVerificationRequirement
diff --git a/tests/pico-fido/test_pin.py b/tests/pico-fido/test_pin.py
index d65f33a..278798b 100644
--- a/tests/pico-fido/test_pin.py
+++ b/tests/pico-fido/test_pin.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import os
import pytest
from fido2.ctap import CtapError
diff --git a/tests/pico-fido/test_register.py b/tests/pico-fido/test_register.py
index 0c104c6..26b6984 100644
--- a/tests/pico-fido/test_register.py
+++ b/tests/pico-fido/test_register.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
from fido2.client import CtapError
from fido2.cose import ES256
import pytest
diff --git a/tests/pico-fido/test_u2f.py b/tests/pico-fido/test_u2f.py
index aa350c7..257dd08 100644
--- a/tests/pico-fido/test_u2f.py
+++ b/tests/pico-fido/test_u2f.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
import pytest
import os
from fido2.ctap1 import APDU, ApduError, Ctap1
diff --git a/tests/utils.py b/tests/utils.py
index 925f402..6bdb5b9 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -1,3 +1,23 @@
+"""
+/*
+ * This file is part of the Pico Fido distribution (https://github.com/polhenarejos/pico-fido).
+ * Copyright (c) 2022 Pol Henarejos.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+"""
+
+
from fido2.webauthn import AttestedCredentialData
import random
import string
@@ -6,6 +26,58 @@ import math
from threading import Event, Timer
from numbers import Number
+import sys
+try:
+ from smartcard.CardType import AnyCardType
+ from smartcard.CardRequest import CardRequest
+ from smartcard.Exceptions import CardRequestTimeoutException, CardConnectionException
+except ModuleNotFoundError:
+ print('ERROR: smarctard module not found! Install pyscard package.\nTry with `pip install pyscard`')
+ sys.exit(-1)
+
+class APDUResponse(Exception):
+ def __init__(self, sw1, sw2):
+ self.sw1 = sw1
+ self.sw2 = sw2
+ super().__init__(f'SW:{sw1:02X}{sw2:02X}')
+
+def send_apdu(card, command, p1, p2, data=None, ne=None):
+ lc = []
+ dataf = []
+ if (data):
+ lc = [0x00] + list(len(data).to_bytes(2, 'big'))
+ dataf = data
+ if (ne is None):
+ le = [0x00, 0x00]
+ else:
+ le = list(ne.to_bytes(2, 'big'))
+ if (isinstance(command, list) and len(command) > 1):
+ apdu = command
+ else:
+ apdu = [0x00, command]
+
+ apdu = apdu + [p1, p2] + lc + dataf + le
+ try:
+ response, sw1, sw2 = card.connection.transmit(apdu)
+ except CardConnectionException:
+ card.connection.reconnect()
+ response, sw1, sw2 = card.connection.transmit(apdu)
+ if (sw1 != 0x90):
+ if (sw1 == 0x6A and sw2 == 0x82):
+ response, sw1, sw2 = card.connection.transmit([0x00, 0xA4, 0x04, 0x00, 0xB, 0xE8, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x81, 0xC3, 0x1F, 0x02, 0x01, 0x0])
+ if (sw1 == 0x90):
+ response, sw1, sw2 = card.connection.transmit(apdu)
+ if (sw1 == 0x90):
+ return response
+ elif (sw1 == 0x69 and sw2 == 0x82):
+ response, sw1, sw2 = card.connection.transmit([0x00, 0x20, 0x00, 0x81, len(pin)] + list(pin.encode()) + [0x0])
+ if (sw1 == 0x90):
+ response, sw1, sw2 = card.connection.transmit(apdu)
+ if (sw1 == 0x90):
+ return response
+ raise APDUResponse(sw1, sw2)
+ return response
+
def verify(MC, GA, client_data_hash):
credential_data = AttestedCredentialData(MC.auth_data.credential_data)