mirror of
https://salsa.debian.org/gnuk-team/gnuk/gnuk.git
synced 2024-09-20 10:50:09 +00:00
key fingerprint and timestamp
This commit is contained in:
parent
3c7a5bff61
commit
e11d81376c
@ -16,3 +16,33 @@ Feature: import keys to token
|
|||||||
Given a RSA key pair 2
|
Given a RSA key pair 2
|
||||||
And importing it to the token as OPENPGP.3
|
And importing it to the token as OPENPGP.3
|
||||||
Then it should get success
|
Then it should get success
|
||||||
|
|
||||||
|
Scenario: setup data object Finger print sig
|
||||||
|
Given a fingerprint of OPENPGP.1 key
|
||||||
|
And put the data to c7
|
||||||
|
Then it should get success
|
||||||
|
|
||||||
|
Scenario: setup data object Finger print dec
|
||||||
|
Given a fingerprint of OPENPGP.2 key
|
||||||
|
And put the data to c8
|
||||||
|
Then it should get success
|
||||||
|
|
||||||
|
Scenario: setup data object Finger print aut
|
||||||
|
Given a fingerprint of OPENPGP.3 key
|
||||||
|
And put the data to c9
|
||||||
|
Then it should get success
|
||||||
|
|
||||||
|
Scenario: setup data object keygeneration data/time sig
|
||||||
|
Given a timestamp of OPENPGP.1 key
|
||||||
|
And put the data to ce
|
||||||
|
Then it should get success
|
||||||
|
|
||||||
|
Scenario: setup data object keygeneration data/time dec
|
||||||
|
Given a timestamp of OPENPGP.2 key
|
||||||
|
And put the data to cf
|
||||||
|
Then it should get success
|
||||||
|
|
||||||
|
Scenario: setup data object keygeneration data/time aut
|
||||||
|
Given a timestamp of OPENPGP.3 key
|
||||||
|
And put the data to d0
|
||||||
|
Then it should get success
|
||||||
|
@ -46,6 +46,23 @@ def import_key(openpgp_keyno_str):
|
|||||||
t = rsa_keys.build_privkey_template(openpgp_keyno, scc.keyno)
|
t = rsa_keys.build_privkey_template(openpgp_keyno, scc.keyno)
|
||||||
scc.result = ftc.token.cmd_put_data_odd(0x3f, 0xff, t)
|
scc.result = ftc.token.cmd_put_data_odd(0x3f, 0xff, t)
|
||||||
|
|
||||||
|
@Given("a fingerprint of OPENPGP.(.*) key")
|
||||||
|
def get_key_fpr(openpgp_keyno_str):
|
||||||
|
openpgp_keyno = int(openpgp_keyno_str)
|
||||||
|
scc.result = rsa_keys.fpr[openpgp_keyno - 1]
|
||||||
|
|
||||||
|
@Given("a timestamp of OPENPGP.(.*) key")
|
||||||
|
def get_key_timestamp(openpgp_keyno_str):
|
||||||
|
openpgp_keyno = int(openpgp_keyno_str)
|
||||||
|
scc.result = rsa_keys.timestamp[openpgp_keyno - 1]
|
||||||
|
|
||||||
|
@Given("put the data to (.*)")
|
||||||
|
def cmd_put_data_with_result(tag_str):
|
||||||
|
tag = int(tag_str, 16)
|
||||||
|
tagh = tag >> 8
|
||||||
|
tagl = tag & 0xff
|
||||||
|
scc.result = ftc.token.cmd_put_data(tagh, tagl, scc.result)
|
||||||
|
|
||||||
@When("requesting (.+): ([0-9a-fA-F]+)")
|
@When("requesting (.+): ([0-9a-fA-F]+)")
|
||||||
def get_data(name, tag_str):
|
def get_data(name, tag_str):
|
||||||
tag = int(tag_str, 16)
|
tag = int(tag_str, 16)
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
|
from time import time
|
||||||
|
from struct import pack
|
||||||
|
from hashlib import sha1
|
||||||
|
|
||||||
def read_key_from_file(file):
|
def read_key_from_file(file):
|
||||||
f = open(file)
|
f = open(file)
|
||||||
@ -15,11 +18,27 @@ def read_key_from_file(file):
|
|||||||
raise ValueError("wrong key", p, q, n)
|
raise ValueError("wrong key", p, q, n)
|
||||||
return (unhexlify(n_str), unhexlify(e_str), unhexlify(p_str), unhexlify(q_str))
|
return (unhexlify(n_str), unhexlify(e_str), unhexlify(p_str), unhexlify(q_str))
|
||||||
|
|
||||||
|
def calc_fpr(n,e):
|
||||||
|
timestamp = int(time())
|
||||||
|
timestamp_data = pack('>I', timestamp)
|
||||||
|
m_len = 6 + 2 + 256 + 2 + 4
|
||||||
|
m = '\x99' + pack('>H', m_len) + '\x04' + timestamp_data + '\x01' + \
|
||||||
|
pack('>H', 2048) + n + pack('>H', 17) + e
|
||||||
|
fpr = sha1(m).digest()
|
||||||
|
return (fpr, timestamp_data)
|
||||||
|
|
||||||
key = [ None, None, None ]
|
key = [ None, None, None ]
|
||||||
|
fpr = [ None, None, None ]
|
||||||
|
timestamp = [ None, None, None ]
|
||||||
|
|
||||||
key[0] = read_key_from_file('rsa-sig.key')
|
key[0] = read_key_from_file('rsa-sig.key')
|
||||||
key[1] = read_key_from_file('rsa-dec.key')
|
key[1] = read_key_from_file('rsa-dec.key')
|
||||||
key[2] = read_key_from_file('rsa-aut.key')
|
key[2] = read_key_from_file('rsa-aut.key')
|
||||||
|
|
||||||
|
(fpr[0], timestamp[0]) = calc_fpr(key[0][0], key[0][1])
|
||||||
|
(fpr[1], timestamp[1]) = calc_fpr(key[1][0], key[1][1])
|
||||||
|
(fpr[2], timestamp[2]) = calc_fpr(key[2][0], key[2][1])
|
||||||
|
|
||||||
def build_privkey_template(openpgp_keyno, keyno):
|
def build_privkey_template(openpgp_keyno, keyno):
|
||||||
n_str = key[keyno][0]
|
n_str = key[keyno][0]
|
||||||
e_str = '\x00' + key[keyno][1]
|
e_str = '\x00' + key[keyno][1]
|
||||||
|
Loading…
Reference in New Issue
Block a user