add keygen test

This commit is contained in:
NIIBE Yutaka
2012-06-28 09:30:16 +09:00
parent 9cc6de9e65
commit 19e677ae74
3 changed files with 83 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
@keygen
Feature: key removal
In order to use a token
A token should have keys
Scenario: remove OPENPGP.1 key (sign)
When removing a key OPENPGP.1
Then it should get success
Scenario: remove OPENPGP.2 key (decrypt)
When removing a key OPENPGP.2
Then it should get success
Scenario: remove OPENPGP.3 key (authentication)
When removing a key OPENPGP.3
Then it should get success
Scenario: remove data object Finger print sig
Given cmd_put_data with c7 and ""
Then it should get success
Scenario: remove data object Finger print dec
Given cmd_put_data with c8 and ""
Then it should get success
Scenario: remove data object Finger print aut
Given cmd_put_data with c9 and ""
Then it should get success
Scenario: remove data object keygeneration data/time sig
Given cmd_put_data with ce and ""
Then it should get success
Scenario: remove data object keygeneration data/time dec
Given cmd_put_data with cf and ""
Then it should get success
Scenario: remove data object keygeneration data/time aut
Given cmd_put_data with d0 and ""
Then it should get success

View File

@@ -0,0 +1,22 @@
@keygen
Feature: key generation
In order to use a token
A token should have keys
Scenario: generate OPENPGP.1 key (sign)
When generating a key of OPENPGP.1
And put the first data to c7
And put the second data to ce
Then it should get success
Scenario: generate OPENPGP.2 key (decrypt)
When generating a key of OPENPGP.2
And put the first data to c8
And put the second data to cf
Then it should get success
Scenario: generate OPENPGP.3 key (authentication)
When generating a key of OPENPGP.3
And put the first data to c9
And put the second data to d0
Then it should get success

View File

@@ -109,6 +109,27 @@ def remove_key(openpgp_keyno_str):
t = rsa_keys.build_privkey_template_for_remove(openpgp_keyno) t = rsa_keys.build_privkey_template_for_remove(openpgp_keyno)
scc.result = ftc.token.cmd_put_data_odd(0x3f, 0xff, t) scc.result = ftc.token.cmd_put_data_odd(0x3f, 0xff, t)
@When("generating a key of OPENPGP.(.*)")
def generate_key(openpgp_keyno_str):
openpgp_keyno = int(openpgp_keyno_str)
pubkey_info = ftc.token.cmd_genkey(openpgp_keyno)
scc.data = rsa_keys.calc_fpr(pubkey_info[0], pubkey_info[1])
@When("put the first data to (.*)")
def cmd_put_data_first_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.data[0])
@When("put the second data to (.*)")
def cmd_put_data_second_with_result(tag_str):
tag = int(tag_str, 16)
tagh = tag >> 8
tagl = tag & 0xff
result = ftc.token.cmd_put_data(tagh, tagl, scc.data[1])
scc.result = (scc.result and result)
@Then("you should get: (.*)") @Then("you should get: (.*)")
def check_result(v): def check_result(v):
value = ast.literal_eval("'" + v + "'") value = ast.literal_eval("'" + v + "'")