def test_vectors():
    """
    Key =          4a656665                          ("Jefe")
   Data =         7768617420646f2079612077616e7420  ("what do ya want ")
                  666f72206e6f7468696e673f          ("for nothing?")

   HMAC-SHA-224 = a30e01098bc6dbbf45690f3a7e9e6d0f
                  8bbea2a39e6148008fd05e44
   HMAC-SHA-256 = 5bdcc146bf60754e6a042426089575c7
                  5a003f089d2739839dec58b964ec3843
   HMAC-SHA-384 = af45d2e376484031617f78d2b58a6b1b
                  9c7ef464f5a01b47e42ec3736322445e
                  8e2240ca5e69e2c78b3239ecfab21649
   HMAC-SHA-512 = 164b7a7bfcf819e2e395fbe73b56e0a3
                  87bd64222e831fd610270cd7ea250554
                  9758bf75c05a994a6d034f65f8f0e6fd
                  caeab1a34d4a6b4b636e070a38bce737
    """

    h = Hmac(b"sha512", b"Jefe")
    assert 512 / 8 == h.outsize
    h.update(b"what do ya want ")
    h.update(b"for nothing?")
    d = h.digest()

    with pytest.raises(Exception) as excinfo:
        h.update(b"some more")
    assert 'finalized' in str(excinfo.value)

    with pytest.raises(Exception) as excinfo:
        h.digest()
    assert 'finalized' in str(excinfo.value)

    with pytest.raises(Exception) as excinfo:
        h = Hmac(b"sha999", b"Jefe")
    assert 'Error' in str(excinfo.value)

    ans1 = hexlify(d)
    ans2 = b"164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737"

    assert len(ans1) == len(ans2)
    assert ans1 == ans2
dataset/ETHPy150Open gdanezis/petlib/petlib/hmac.py/test_vectors/original