Exemple #1
0
def test_warning_binary_bigger_than_secret_buffer(C):
    invalid_hex_string = to_hex('1234567890') * 3
    invalid_hex_string = invalid_hex_string.encode('ascii')
    if is_long_OTP_secret_handled(C):
        invalid_hex_string *= 2
    assert C.NK_write_hotp_slot(1, b'slot_name', invalid_hex_string, 0, True, False, False, b'',
                                DefaultPasswords.ADMIN_TEMP) == LibraryErrors.TARGET_BUFFER_SIZE_SMALLER_THAN_SOURCE
Exemple #2
0
def test_warning_binary_bigger_than_secret_buffer(C):
    invalid_hex_string = to_hex('1234567890') * 3
    if is_long_OTP_secret_handled(C):
        invalid_hex_string *= 2
    assert C.NK_write_hotp_slot(
        1, 'slot_name', invalid_hex_string, 0, True, False, False, '',
        DefaultPasswords.ADMIN_TEMP
    ) == LibraryErrors.TARGET_BUFFER_SIZE_SMALLER_THAN_SOURCE
Exemple #3
0
GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with libnitrokey. If not, see <http://www.gnu.org/licenses/>.

SPDX-License-Identifier: LGPL-3.0
"""

from misc import to_hex

def bb(x):
    return bytes(x, encoding='ascii')


RFC_SECRET_HR = '12345678901234567890'
RFC_SECRET = to_hex(RFC_SECRET_HR)  # '31323334353637383930...'
bbRFC_SECRET = bb(RFC_SECRET)


# print( repr((RFC_SECRET, RFC_SECRET_, len(RFC_SECRET))) )

class DefaultPasswords:
    ADMIN = b'12345678'
    USER = b'123456'
    ADMIN_TEMP = b'123123123'
    USER_TEMP = b'234234234'
    UPDATE = b'12345678'
    UPDATE_TEMP = b'123update123'


class DeviceErrorCode: