Skip to content

Commit

Permalink
fix orders in test
Browse files Browse the repository at this point in the history
  • Loading branch information
dangfan committed Dec 24, 2023
1 parent 49c2727 commit 0c2a5b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 4 additions & 0 deletions applets/piv/piv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,10 @@ static int piv_get_serial(const CAPDU *capdu, RAPDU *rapdu) {
}

static int piv_algorithm_extension(const CAPDU *capdu, RAPDU *rapdu) {
#ifndef FUZZ
if (!in_admin_status) EXCEPT(SW_SECURITY_STATUS_NOT_SATISFIED);
#endif

if (P1 != 0x01 && P1 != 0x02) EXCEPT(SW_WRONG_P1P2);
if (P2 != 0x00) EXCEPT(SW_WRONG_P1P2);

Expand Down
15 changes: 5 additions & 10 deletions test-via-pcsc/piv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (o *PIVApplet) Send(apdu []byte) ([]byte, uint16, error) {
return res[0 : len(res)-2], uint16(res[len(res)-2])<<8 | uint16(res[len(res)-1]), nil
}
func (app *PIVApplet) ConfigPIVAlgoExt(enable uint8) {
_, code, err := app.Send([]byte{0x00, 0xEE, 0x02, 0x00, 0x07, enable, 0x00, 0x00, 0x00, 0x00})
_, code, err := app.Send([]byte{0x00, 0xEE, 0x02, 0x00, 0x07, enable, 0x22, 0x50, 0x51, 0x52, 0x53, 0x54})
So(err, ShouldBeNil)
So(code, ShouldEqual, 0x9000)
}
Expand Down Expand Up @@ -117,15 +117,15 @@ func TestPIVExtensions(t *testing.T) {
So(err, ShouldBeNil)
defer app.Close()

Convey("Enable algorithm extension", func(ctx C) {
app.ConfigPIVAlgoExt(1)
})

Convey("Select the Applet and Authenticate", func(ctx C) {
app.Select()
app.Authenticate()
})

Convey("Enable algorithm extension", func(ctx C) {
app.ConfigPIVAlgoExt(1)
})

Convey("Generate the key", func(ctx C) {
for keyID := 0x50; keyID <= 0x54; keyID++ {
_, code, err := app.Send([]byte{0x00, 0x47, 0x00, 0x9E, 0x05, 0xAC, 0x03, 0x80, 0x01, byte(keyID)})
Expand All @@ -140,11 +140,6 @@ func TestPIVExtensions(t *testing.T) {
app.ConfigPIVAlgoExt(0)
})

Convey("Select the Applet and Authenticate again", func(ctx C) {
app.Select()
app.Authenticate()
})

Convey("Generate the key again", func(ctx C) {
for keyID := 0x50; keyID <= 0x54; keyID++ {
_, code, err := app.Send([]byte{0x00, 0x47, 0x00, 0x9E, 0x05, 0xAC, 0x03, 0x80, 0x01, byte(keyID)})
Expand Down

0 comments on commit 0c2a5b8

Please sign in to comment.