-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,195 additions
and
605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
repos: | ||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
sha: v0.8.0 | ||
sha: v1.1.1 | ||
hooks: | ||
- id: flake8 | ||
- id: double-quote-string-fixer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
yubikey-manager (0.2.0~ppa1) xenial; urgency=low | ||
yubikey-manager (0.5.0) xenial; urgency=low | ||
|
||
* Build for ppa | ||
|
||
-- Dag Heyman <dag@yubico.com> Fri, 18 Nov 2016 14:14:54 +0100 | ||
-- Emil Lundberg <emil@yubico.com> Tue, 17 Oct 2017 17:19:03 +0200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
Source: yubikey-manager | ||
Maintainer: Debian Authentication Maintainers <[email protected]> | ||
Uploaders: Dag Heyman <[email protected]>, | ||
Dain Nilsson <[email protected]> | ||
Dain Nilsson <[email protected]>, | ||
Emil Lundberg <[email protected]> | ||
Section: utils | ||
Priority: optional | ||
Standards-Version: 3.9.7 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,94 @@ | ||
from ykman.oath import Credential | ||
# vim: set fileencoding=utf-8 : | ||
|
||
from ykman.oath import Credential, CredentialData, _derive_key, OATH_TYPE, ALGO | ||
import unittest | ||
|
||
|
||
class TestOathFunctions(unittest.TestCase): | ||
|
||
def test_credential_parse_period_and_issuer_and_name(self): | ||
period, issuer, name = Credential.parse_long_name('20/Issuer:name') | ||
issuer, name, period = Credential.parse_key(b'20/Issuer:name') | ||
self.assertEqual(20, period) | ||
self.assertEqual('Issuer', issuer) | ||
self.assertEqual('name', name) | ||
|
||
def test_credential_parse_wierd_issuer_and_name(self): | ||
period, issuer, name = Credential.parse_long_name('wierd/Issuer:name') | ||
issuer, name, period = Credential.parse_key(b'wierd/Issuer:name') | ||
self.assertEqual(30, period) | ||
self.assertEqual('wierd/Issuer', issuer) | ||
self.assertEqual('name', name) | ||
|
||
def test_credential_parse_issuer_and_name(self): | ||
period, issuer, name = Credential.parse_long_name('Issuer:name') | ||
issuer, name, period = Credential.parse_key(b'Issuer:name') | ||
self.assertEqual(30, period) | ||
self.assertEqual('Issuer', issuer) | ||
self.assertEqual('name', name) | ||
|
||
def test_credential_parse_period_and_name(self): | ||
period, issuer, name = Credential.parse_long_name('20/name') | ||
issuer, name, period = Credential.parse_key(b'20/name') | ||
self.assertEqual(20, period) | ||
self.assertEqual(None, issuer) | ||
self.assertIsNone(issuer) | ||
self.assertEqual('name', name) | ||
|
||
def test_credential_parse_only_name(self): | ||
period, issuer, name = Credential.parse_long_name('name') | ||
issuer, name, period = Credential.parse_key(b'name') | ||
self.assertEqual(30, period) | ||
self.assertEqual(None, issuer) | ||
self.assertIsNone(issuer) | ||
self.assertEqual('name', name) | ||
|
||
def test_credential_serialize_name(self): | ||
self.assertEqual('name', Credential('name').long_name) | ||
self.assertEqual( | ||
'Issuer:name', Credential('name', issuer='Issuer').long_name) | ||
self.assertEqual( | ||
'20/Issuer:name', Credential( | ||
'name', issuer='Issuer', period=20).long_name) | ||
self.assertEqual( | ||
'Issuer:name', Credential( | ||
'name', issuer='Issuer', period=30).long_name) | ||
def test_credential_data_make_key(self): | ||
self.assertEqual(b'name', CredentialData(b'', None, 'name').make_key()) | ||
self.assertEqual(b'Issuer:name', | ||
CredentialData(b'', 'Issuer', 'name').make_key()) | ||
self.assertEqual(b'20/Issuer:name', | ||
CredentialData(b'', 'Issuer', 'name', period=20 | ||
).make_key()) | ||
self.assertEqual(b'Issuer:name', | ||
CredentialData(b'', 'Issuer', 'name', period=30 | ||
).make_key()) | ||
self.assertEqual(b'20/name', | ||
CredentialData(b'', None, 'name', period=20 | ||
).make_key()) | ||
|
||
def test_derive_key(self): | ||
self.assertEqual( | ||
'20/name', Credential('name', period=20).long_name) | ||
b'\xb0}\xa1\xe7\xde\x87\xf8\x9a\x87\xa2\xb5\x98\xea\xa2\x18\x8c', | ||
_derive_key(b'\0\0\0\0\0\0\0\0', u'foobar')) | ||
self.assertEqual( | ||
'Issuer:name', Credential( | ||
'name', issuer='Issuer', period=None).long_name) | ||
b'\xda\x81\x8ek,\xf0\xa2\xd0\xbf\x19\xb3\xdd\xd3K\x83\xf5', | ||
_derive_key(b'12345678', u'Hallå världen!')) | ||
self.assertEqual( | ||
'name', Credential('name', period=None).long_name) | ||
|
||
def test_credential_expiration(self): | ||
cred = Credential('name') | ||
cred.update_expiration(0) | ||
self.assertEqual(30, cred.expiration) | ||
cred.update_expiration(30) | ||
self.assertEqual(60, cred.expiration) | ||
cred.update_expiration(60) | ||
self.assertEqual(90, cred.expiration) | ||
b'\xf3\xdf\xa7\x81T\xc8\x102\x99E\xfb\xc4\xb55\xe57', | ||
_derive_key(b'saltsalt', u'Ťᶒśƫ ᵽĥřӓşḛ')) | ||
|
||
def test_parse_uri_issuer(self): | ||
no_issuer = CredentialData.from_uri('otpauth://totp/account' | ||
'?secret=abba') | ||
self.assertIsNone(no_issuer.issuer) | ||
|
||
from_param = CredentialData.from_uri('otpauth://totp/account' | ||
'?secret=abba&issuer=Test') | ||
self.assertEqual('Test', from_param.issuer) | ||
|
||
from_name = CredentialData.from_uri('otpauth://totp/Test:account' | ||
'?secret=abba') | ||
self.assertEqual('Test', from_name.issuer) | ||
|
||
with_both = CredentialData.from_uri('otpauth://totp/TestA:account' | ||
'?secret=abba&issuer=TestB') | ||
self.assertEqual('TestB', with_both.issuer) | ||
|
||
def test_parse_uri(self): | ||
data = CredentialData.from_uri('otpauth://totp/Issuer:account' | ||
'?secret=abba&issuer=Issuer' | ||
'&algorithm=SHA256&digits=7' | ||
'&period=20&counter=5') | ||
self.assertEqual(b'\0B', data.secret) | ||
self.assertEqual('Issuer', data.issuer) | ||
self.assertEqual('account', data.name) | ||
self.assertEqual(OATH_TYPE.TOTP, data.oath_type) | ||
self.assertEqual(ALGO.SHA256, data.algorithm) | ||
self.assertEqual(7, data.digits) | ||
self.assertEqual(20, data.period) | ||
self.assertEqual(5, data.counter) | ||
self.assertEqual(False, data.touch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.