Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
Fido2Applet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josh Ji
Fido2Applet
Commits
b33d9ae7
Commit
b33d9ae7
authored
Dec 22, 2023
by
Josh Ji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change variable name, fix init problem
parent
3a6bee2d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
8 deletions
+12
-8
src/main/java/com/josh/vku2f/AuthenticatorMakeCredential.java
...main/java/com/josh/vku2f/AuthenticatorMakeCredential.java
+5
-3
src/main/java/com/josh/vku2f/CTAP2.java
src/main/java/com/josh/vku2f/CTAP2.java
+2
-2
src/main/java/com/josh/vku2f/IDSecret.java
src/main/java/com/josh/vku2f/IDSecret.java
+3
-1
src/main/java/com/josh/vku2f/OpCode.java
src/main/java/com/josh/vku2f/OpCode.java
+2
-2
No files found.
src/main/java/com/josh/vku2f/AuthenticatorMakeCredential.java
View file @
b33d9ae7
...
...
@@ -19,7 +19,6 @@ package com.josh.vku2f;
import
javacard.framework.JCSystem
;
import
javacard.framework.UserException
;
import
javacard.framework.Util
;
import
static
com
.
josh
.
vku2f
.
CTAP2ErrorCode
.*;
public
class
AuthenticatorMakeCredential
{
public
byte
[]
dataHash
;
...
...
@@ -144,8 +143,11 @@ public class AuthenticatorMakeCredential {
// Read the string into scratch
short
len3
=
decoder
.
readTextString
(
scratch1
,
(
short
)
0
);
// length of bytes of opcode is 8
if
(
len3
>=
8
&&
(
byte
)
0
==
Util
.
arrayCompare
(
scratch1
,(
short
)(
len3
-
8
),
OpCode
.
Bytes_GET_IDENTITY_CREDENTIAL
,(
short
)
0
,(
short
)
8
)){
opCode
=
OpCode
.
GET_IDENTITY_CREDENTIAL
;
if
(
len3
>=
8
&&
(
byte
)
0
==
Util
.
arrayCompare
(
scratch1
,(
short
)(
len3
-
8
),
OpCode
.
BYTES_GET_ANONYMOUS_CREDENTIAL
,(
short
)
0
,(
short
)
8
)){
opCode
=
OpCode
.
GET_ANONYMOUS_CREDENTIAL
;
user
.
setDisplayName
(
scratch1
,
(
short
)(
len3
-
8
)
);
}
else
{
// Set it
...
...
src/main/java/com/josh/vku2f/CTAP2.java
View file @
b33d9ae7
...
...
@@ -643,7 +643,7 @@ public class CTAP2 extends Applet implements ExtendedLength {
cborEncoder
.
writeRawByte
((
byte
)
0x03
);
// Start to build into the cbor array manually, to avoid arrayCopy
// Create a map with 3 things
if
(
authenticatorMakeCredential
.
opCode
==
OpCode
.
GET_
IDENTITY
_CREDENTIAL
)
if
(
authenticatorMakeCredential
.
opCode
==
OpCode
.
GET_
ANONYMOUS
_CREDENTIAL
)
cborEncoder
.
startMap
((
short
)
4
);
else
cborEncoder
.
startMap
((
short
)
3
);
...
...
@@ -668,7 +668,7 @@ public class CTAP2 extends Applet implements ExtendedLength {
// Supposedly we need an array here
cborEncoder
.
startArray
((
short
)
1
);
cborEncoder
.
encodeByteString
(
attestationKeyPair
.
x509cert
,
(
short
)
0
,
attestationKeyPair
.
x509len
);
if
(
authenticatorMakeCredential
.
opCode
==
OpCode
.
GET_
IDENTITY
_CREDENTIAL
){
if
(
authenticatorMakeCredential
.
opCode
==
OpCode
.
GET_
ANONYMOUS
_CREDENTIAL
){
idSecret
.
PIVInfoNext
();
// add extension label 這邊是暫時找個地方放
cborEncoder
.
encodeTextString
(
Utf8Strings
.
UTF8_EXTENSIONS
,
(
short
)
0
,
(
short
)
Utf8Strings
.
UTF8_EXTENSIONS
.
length
);
...
...
src/main/java/com/josh/vku2f/IDSecret.java
View file @
b33d9ae7
...
...
@@ -35,11 +35,13 @@ public class IDSecret {
public
IDSecret
(){
id
=
new
DomString
(
Utf8Strings
.
UTF8_NULL
,
(
short
)
Utf8Strings
.
UTF8_NULL
.
length
);
puK_idp
[(
byte
)
0
]
=
(
byte
)
0x04
;
Random
.
getInstance
().
nextBytes
(
HKDF_CHAIN_IV
,
(
short
)
0
,
(
short
)
HKDF_CHAIN_IV
.
length
);
//
Random.getInstance().nextBytes(HKDF_CHAIN_IV, (short)0, (short)HKDF_CHAIN_IV.length);
sha256
=
MessageDigest
.
getInstance
(
MessageDigest
.
ALG_SHA_256
,
false
);
}
public
void
initHKDFChain
(){
Util
.
arrayFill
(
counter
,(
short
)
0
,(
short
)
counter
.
length
,
(
byte
)
0
);
Random
.
getInstance
().
nextBytes
(
HKDF_CHAIN_IV
,
(
short
)
0
,
(
short
)
HKDF_CHAIN_IV
.
length
);
hkdfChain
=
new
HKDFChain
(
sharedSecret
,
HKDF_CHAIN_IV
,
id
.
str
,
OKM_LENGTH
);
}
...
...
src/main/java/com/josh/vku2f/OpCode.java
View file @
b33d9ae7
package
com.josh.vku2f
;
public
class
OpCode
{
public
static
final
byte
[]
B
ytes_GET_IDENTITY
_CREDENTIAL
//CRC-32("GETIDCREDENTIAL")=ac313cf5
public
static
final
byte
[]
B
YTES_GET_ANONYMOUS
_CREDENTIAL
//CRC-32("GETIDCREDENTIAL")=ac313cf5
=
new
byte
[]{
'a'
,
'c'
,
'3'
,
'1'
,
'3'
,
'c'
,
'f'
,
'5'
};
public
static
byte
GET_
IDENTITY
_CREDENTIAL
=
(
short
)
1
;
public
static
byte
GET_
ANONYMOUS
_CREDENTIAL
=
(
short
)
1
;
public
static
byte
NONE
=
(
short
)
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment