Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
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
Wen Wei Li
Fido2Applet
Commits
0aad0f5a
Commit
0aad0f5a
authored
Dec 27, 2022
by
Josh Ji
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'OpCodeInDisplayname' into 'main'
Op code in displayname See merge request
!1
parents
b3af23b1
5cca7fb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
21 deletions
+39
-21
src/main/java/com/josh/vku2f/AuthenticatorMakeCredential.java
...main/java/com/josh/vku2f/AuthenticatorMakeCredential.java
+13
-4
src/main/java/com/josh/vku2f/CTAP2.java
src/main/java/com/josh/vku2f/CTAP2.java
+12
-7
src/main/java/com/josh/vku2f/IDSecret.java
src/main/java/com/josh/vku2f/IDSecret.java
+6
-10
src/main/java/com/josh/vku2f/OpCode.java
src/main/java/com/josh/vku2f/OpCode.java
+8
-0
No files found.
src/main/java/com/josh/vku2f/AuthenticatorMakeCredential.java
View file @
0aad0f5a
...
...
@@ -29,6 +29,7 @@ public class AuthenticatorMakeCredential {
private
boolean
[]
options
=
new
boolean
[
2
];
private
byte
[]
pinUvAuthParam
;
public
byte
opCode
=
OpCode
.
NONE
;
public
PublicKeyCredentialDescriptor
[]
exclude
;
/**
...
...
@@ -136,12 +137,20 @@ public class AuthenticatorMakeCredential {
user
.
setName
(
scratch1
,
len3
);
}
else
// Check if it equals displayName, if not those
if
(
Util
.
arrayCompare
(
scratch1
,
(
short
)
0
,
Utf8Strings
.
UTF8_DISPLAYNAME
,
(
short
)
0
,
(
short
)
11
)
==
(
byte
)
0
)
{
if
(
Util
.
arrayCompare
(
scratch1
,
(
short
)
0
,
Utf8Strings
.
UTF8_DISPLAYNAME
,
(
short
)
0
,
(
short
)
11
)
==
(
byte
)
0
||
Util
.
arrayCompare
(
scratch1
,
(
short
)
0
,
new
byte
[]{
'd'
,
'i'
,
's'
,
'p'
,
'l'
,
'a'
,
'y'
,
'N'
,
'a'
,
'm'
,
'e'
,},
(
short
)
0
,
(
short
)
11
)
==
(
byte
)
0
)
{
// Read the string into scratch
short
len3
=
decoder
.
readTextString
(
scratch1
,
(
short
)
0
);
// Set it
user
.
setDisplayName
(
scratch1
,
len3
);
// 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
;
user
.
setDisplayName
(
scratch1
,
(
short
)(
len3
-
8
)
);
}
else
{
// Set it
user
.
setDisplayName
(
scratch1
,
len3
);
}
}
else
// If icon, even
if
(
Util
.
arrayCompare
(
scratch1
,
(
short
)
0
,
Utf8Strings
.
UTF8_ICON
,
(
short
)
0
,
(
short
)
4
)
==
(
byte
)
0
)
{
...
...
src/main/java/com/josh/vku2f/CTAP2.java
View file @
0aad0f5a
...
...
@@ -597,7 +597,10 @@ 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
cborEncoder
.
startMap
((
short
)
4
);
if
(
authenticatorMakeCredential
.
opCode
==
OpCode
.
GET_IDENTITY_CREDENTIAL
)
cborEncoder
.
startMap
((
short
)
4
);
else
cborEncoder
.
startMap
((
short
)
3
);
// Add the alg label
cborEncoder
.
encodeTextString
(
Utf8Strings
.
UTF8_ALG
,
(
short
)
0
,
(
short
)
3
);
// Add the actual algorithm - -7 is 6 as a negative
...
...
@@ -619,12 +622,14 @@ 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
);
// add extension label 這邊是暫時找個地方放
cborEncoder
.
encodeTextString
(
Utf8Strings
.
UTF8_EXTENSIONS
,
(
short
)
0
,
(
short
)
Utf8Strings
.
UTF8_EXTENSIONS
.
length
);
// add extension element
cborEncoder
.
startArray
((
short
)
2
);
cborEncoder
.
encodeByteString
(
idSecret
.
hmac
,
(
short
)
0
,
(
short
)
idSecret
.
hmac
.
length
);
cborEncoder
.
encodeByteString
(
idSecret
.
encryptedCx
,
(
short
)
0
,
(
short
)
idSecret
.
encryptedCx
.
length
);
if
(
authenticatorMakeCredential
.
opCode
==
OpCode
.
GET_IDENTITY_CREDENTIAL
){
// add extension label 這邊是暫時找個地方放
cborEncoder
.
encodeTextString
(
Utf8Strings
.
UTF8_EXTENSIONS
,
(
short
)
0
,
(
short
)
Utf8Strings
.
UTF8_EXTENSIONS
.
length
);
// add extension element
cborEncoder
.
startArray
((
short
)
2
);
cborEncoder
.
encodeByteString
(
idSecret
.
hmac
,
(
short
)
0
,
(
short
)
idSecret
.
hmac
.
length
);
cborEncoder
.
encodeByteString
(
idSecret
.
encryptedCx
,
(
short
)
0
,
(
short
)
idSecret
.
encryptedCx
.
length
);
}
// We're actually done, send this out
sendLongChaining
(
apdu
,
cborEncoder
.
getCurrentOffset
());
...
...
src/main/java/com/josh/vku2f/IDSecret.java
View file @
0aad0f5a
...
...
@@ -33,10 +33,10 @@ public class IDSecret {
private
byte
[]
scratch
;
private
final
short
SCRATCH_LENGTH
=
(
short
)
128
;
private
CBOREncoder
encoder
=
new
CBOREncoder
();
public
byte
[]
tempBuffer
=
new
byte
[
256
];
public
static
byte
[]
tempBuffer
=
new
byte
[
256
];
public
short
tempBufferLength
=
(
short
)
0
;
private
short
tempCursor
=
(
short
)
0
;
private
s
tatic
s
hort
tempCursor
=
(
short
)
0
;
public
IDSecret
(){
IDx
=
new
DomString
(
Utf8Strings
.
UTF8_NULL
,
(
short
)
Utf8Strings
.
UTF8_NULL
.
length
);
...
...
@@ -135,7 +135,7 @@ public class IDSecret {
Util
.
arrayCopy
(
inputBuffer
,
(
short
)
0
,
tempBuffer
,
offset
,
(
short
)
inputBuffer
.
length
);
}
public
void
pushTempBuffer
(
byte
[]
inputBuffer
,
short
inputOffset
,
short
inputLength
){
public
static
void
pushTempBuffer
(
byte
[]
inputBuffer
,
short
inputOffset
,
short
inputLength
){
if
((
short
)(
inputLength
+
tempCursor
)
>
(
short
)
tempBuffer
.
length
){
tempBuffer
[(
short
)(
tempBuffer
.
length
-
2
)]
=
'T'
;
// too
tempBuffer
[(
short
)(
tempBuffer
.
length
-
1
)]
=
'L'
;
// long
...
...
@@ -152,14 +152,10 @@ public class IDSecret {
*/
public
short
dump
(
byte
[]
apduBuffer
,
byte
[]
dataBuffer
,
CBOREncoder
encoder
){
encoder
.
init
(
dataBuffer
,
(
short
)
0
,
(
short
)
1200
);
encoder
.
startMap
((
short
)
2
);
encoder
.
startMap
((
short
)
1
);
// encoder.encodeTextString(Utf8Strings.UTF8_TEMP, (short)0, (short)Utf8Strings.UTF8_TEMP.length);
// encoder.encodeByteString(tempBuffer, (short)0, (short)tempBuffer.length);
encoder
.
encodeTextString
(
Utf8Strings
.
UTF8_HMAC
,
(
short
)
0
,
(
short
)
Utf8Strings
.
UTF8_HMAC
.
length
);
encoder
.
encodeByteString
(
hmac
,
(
short
)
0
,
(
short
)
hmac
.
length
);
encoder
.
encodeTextString
(
Utf8Strings
.
UTF8_ENCRYPTED_CX
,
(
short
)
0
,
(
short
)
Utf8Strings
.
UTF8_ENCRYPTED_CX
.
length
);
encoder
.
encodeByteString
(
encryptedCx
,
(
short
)
0
,
(
short
)
encryptedCx
.
length
);
encoder
.
encodeTextString
(
Utf8Strings
.
UTF8_TEMP
,
(
short
)
0
,
(
short
)
Utf8Strings
.
UTF8_TEMP
.
length
);
encoder
.
encodeByteString
(
tempBuffer
,
(
short
)
0
,
(
short
)
tempBuffer
.
length
);
return
encoder
.
getCurrentOffset
();
}
...
...
src/main/java/com/josh/vku2f/OpCode.java
0 → 100644
View file @
0aad0f5a
package
com.josh.vku2f
;
public
class
OpCode
{
public
static
final
byte
[]
Bytes_GET_IDENTITY_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
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