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
ba3ad98f
An error occurred while fetching merge requests data.
Commit
ba3ad98f
authored
3 years ago
by
Josh Ji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client Pin not finished
parent
d270c116
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
425 additions
and
138 deletions
+425
-138
.idea/codeStyles/codeStyleConfig.xml
.idea/codeStyles/codeStyleConfig.xml
+5
-0
src/main/java/com/josh/vku2f/COSEKey.java
src/main/java/com/josh/vku2f/COSEKey.java
+18
-0
src/main/java/com/josh/vku2f/CTAP2.java
src/main/java/com/josh/vku2f/CTAP2.java
+117
-138
src/main/java/com/josh/vku2f/ClientPIN.java
src/main/java/com/josh/vku2f/ClientPIN.java
+28
-0
src/main/java/com/josh/vku2f/ClientPINCommand.java
src/main/java/com/josh/vku2f/ClientPINCommand.java
+100
-0
src/main/java/com/josh/vku2f/ClientPINResponse.java
src/main/java/com/josh/vku2f/ClientPINResponse.java
+9
-0
src/main/java/com/josh/vku2f/ClientPINSubCommand.java
src/main/java/com/josh/vku2f/ClientPINSubCommand.java
+13
-0
src/main/java/com/josh/vku2f/PinUvAuthProtocol.java
src/main/java/com/josh/vku2f/PinUvAuthProtocol.java
+14
-0
src/main/java/com/josh/vku2f/PinUvAuthProtocolOne.java
src/main/java/com/josh/vku2f/PinUvAuthProtocolOne.java
+86
-0
src/main/java/com/josh/vku2f/PinUvAuthToken.java
src/main/java/com/josh/vku2f/PinUvAuthToken.java
+35
-0
No files found.
.idea/codeStyles/codeStyleConfig.xml
0 → 100644
View file @
ba3ad98f
<component
name=
"ProjectCodeStyleConfiguration"
>
<state>
<option
name=
"PREFERRED_PROJECT_CODE_STYLE"
value=
"Default"
/>
</state>
</component>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/COSEKey.java
0 → 100644
View file @
ba3ad98f
package
com.josh.vku2f
;
public
class
COSEKey
{
private
byte
[]
w
;
COSEKey
(){
w
=
new
byte
[
64
];
}
public
void
setW
(
byte
[]
w
){
this
.
w
=
w
;
}
public
byte
[]
getW
(){
return
w
;
}
public
void
encode
(
CBOREncoder
cborEncoder
){
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/CTAP2.java
View file @
ba3ad98f
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/ClientPIN.java
0 → 100644
View file @
ba3ad98f
package
com.josh.vku2f
;
import
javacard.framework.JCSystem
;
public
class
ClientPIN
{
private
short
i
;
// counter
private
byte
[]
PIN
;
private
boolean
[]
checked
;
ClientPIN
(){
checked
=
JCSystem
.
makeTransientBooleanArray
((
short
)
1
,
JCSystem
.
CLEAR_ON_DESELECT
);
}
public
boolean
checkPIN
(
byte
[]
pin
){
if
(
PIN
.
length
!=
pin
.
length
){
return
false
;
}
for
(
i
=
0
;
i
<
PIN
.
length
;
i
++){
if
(
PIN
[
i
]
!=
pin
[
i
])
{
return
false
;
}
}
checked
[
0
]
=
true
;
return
true
;
}
public
void
setPIN
(){
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/ClientPINCommand.java
0 → 100644
View file @
ba3ad98f
package
com.josh.vku2f
;
import
javacard.framework.UserException
;
public
class
ClientPINCommand
{
public
static
final
byte
PARAMETER_PROTOCOL
=
0x01
;
public
static
final
byte
PARAMETER_SUBCOMMAND
=
0x02
;
public
static
final
byte
PARAMETER_KEY_AGREEMENT
=
0x03
;
public
static
final
byte
PARAMETER_PIN_UV_AUTH_PARAM
=
0x04
;
public
static
final
byte
PARAMETER_NEW_PIN_ENC
=
0x05
;
public
static
final
byte
PARAMETER_PIN_HASH_ENC
=
0x06
;
public
static
final
byte
PARAMETER_PERMISSIONS
=
0x09
;
public
static
final
byte
PARAMETER_RP_ID
=
0x0A
;
private
byte
protocol
;
// unsigned int
private
byte
subCommandCode
;
// unsigned int
private
byte
[]
keyAgreement
;
// COSE object
private
byte
[]
pinUvAuthParam
;
// byte string
private
byte
[]
newPinEnc
;
// byte string
private
byte
[]
pinHashEnc
;
// byte string
private
byte
permissions
;
// unsigned int
private
byte
[]
rpId
;
// text string
public
void
decodeCommand
(
CBORDecoder
cborDecoder
)
throws
UserException
{
short
commandLength
=
cborDecoder
.
readMajorType
(
CBORBase
.
TYPE_MAP
);
do
{
byte
commandKey
=
cborDecoder
.
readInt8
();
short
valueLength
;
switch
(
commandKey
)
{
case
PARAMETER_PROTOCOL:
protocol
=
cborDecoder
.
readInt8
();
break
;
case
PARAMETER_SUBCOMMAND:
subCommandCode
=
cborDecoder
.
readInt8
();
break
;
case
PARAMETER_KEY_AGREEMENT:
valueLength
=
cborDecoder
.
readLength
();
keyAgreement
=
new
byte
[
valueLength
];
cborDecoder
.
readRawByteArray
(
keyAgreement
,
(
short
)
0
,
valueLength
);
break
;
case
PARAMETER_PIN_UV_AUTH_PARAM:
valueLength
=
cborDecoder
.
readLength
();
pinUvAuthParam
=
new
byte
[
valueLength
];
cborDecoder
.
readRawByteArray
(
pinUvAuthParam
,
(
short
)
0
,
valueLength
);
break
;
case
PARAMETER_NEW_PIN_ENC:
valueLength
=
cborDecoder
.
readLength
();
newPinEnc
=
new
byte
[
valueLength
];
cborDecoder
.
readRawByteArray
(
newPinEnc
,
(
short
)
0
,
valueLength
);
break
;
case
PARAMETER_PIN_HASH_ENC:
valueLength
=
cborDecoder
.
readLength
();
pinHashEnc
=
new
byte
[
valueLength
];
cborDecoder
.
readRawByteArray
(
pinHashEnc
,
(
short
)
0
,
valueLength
);
break
;
case
PARAMETER_PERMISSIONS:
permissions
=
cborDecoder
.
readInt8
();
break
;
case
PARAMETER_RP_ID:
valueLength
=
cborDecoder
.
readLength
();
rpId
=
new
byte
[
valueLength
];
cborDecoder
.
readRawByteArray
(
rpId
,
(
short
)
0
,
valueLength
);
break
;
}
commandLength
--;
}
while
(
commandLength
>=
1
);
}
public
byte
getProtocol
()
{
return
protocol
;
}
public
byte
getSubCommandCode
()
{
return
subCommandCode
;
}
public
byte
[]
getKeyAgreement
()
{
return
keyAgreement
;
}
public
byte
[]
getPinUvAuthParam
()
{
return
pinUvAuthParam
;
}
public
byte
[]
getNewPinEnc
()
{
return
newPinEnc
;
}
public
byte
[]
getPinHashEnc
()
{
return
pinHashEnc
;
}
public
byte
getPermissions
()
{
return
permissions
;
}
public
byte
[]
getRpId
()
{
return
rpId
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/ClientPINResponse.java
0 → 100644
View file @
ba3ad98f
package
com.josh.vku2f
;
public
class
ClientPINResponse
{
public
static
byte
KEY_AGREEMENT
=
(
byte
)
0x01
;
public
static
byte
PIN_UV_AUTH_TOKEN
=
(
byte
)
0x02
;
public
static
byte
PIN_RETRIES
=
(
byte
)
0x03
;
public
static
byte
POWER_CYCLE_STATE
=
(
byte
)
0x04
;
public
static
byte
UV_RETRIES
=
(
byte
)
0x05
;
}
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/ClientPINSubCommand.java
0 → 100644
View file @
ba3ad98f
package
com.josh.vku2f
;
public
class
ClientPINSubCommand
{
public
static
final
byte
SUBCOMMAND_GET_PIN_RETRIES
=
(
byte
)
0x01
;
public
static
final
byte
SUBCOMMAND_GET_KEY_AGREEMENT
=
(
byte
)
0x02
;
public
static
final
byte
SUBCOMMAND_SET_PIN
=
(
byte
)
0x03
;
public
static
final
byte
SUBCOMMAND_CHANGE_PIN
=
(
byte
)
0x04
;
public
static
final
byte
SUBCOMMAND_GET_PIN_TOKEN
=
(
byte
)
0x05
;
public
static
final
byte
SUBCOMMAND_GET_PIN_UV_AUTH_TOKEN_UV
=
(
byte
)
0x06
;
public
static
final
byte
SUBCOMMAND_GET_UV_RETRIES
=
(
byte
)
0x07
;
// no 0x08
public
static
final
byte
SUBCOMMAND_GET_PIN_UV_AUTH_TOKEN_PIN
=
(
byte
)
0x09
;
}
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/PinUvAuthProtocol.java
0 → 100644
View file @
ba3ad98f
package
com.josh.vku2f
;
public
abstract
class
PinUvAuthProtocol
{
private
PinUvAuthToken
pinUvAuthToken
;
public
abstract
void
initialize
();
public
abstract
void
regenerate
();
public
abstract
void
resetPinUvAuthToken
();
public
abstract
byte
[]
getPublicKey
();
public
abstract
byte
[]
decapsulate
(
COSEKey
peerCoseKey
);
public
abstract
void
decrypt
(
byte
[]
sharedSecret
,
byte
[]
cipherText
);
public
abstract
void
verify
(
byte
[]
key
,
byte
[]
message
,
byte
[]
signature
);
}
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/PinUvAuthProtocolOne.java
0 → 100644
View file @
ba3ad98f
package
com.josh.vku2f
;
import
javacard.framework.JCSystem
;
import
javacard.security.*
;
public
class
PinUvAuthProtocolOne
extends
PinUvAuthProtocol
{
private
KeyPair
ecDhKeyPair
;
private
boolean
[]
ecDhSet
;
@Override
public
void
initialize
()
{
ECPublicKey
ecDhPub
=
(
ECPublicKey
)
KeyBuilder
.
buildKey
(
KeyBuilder
.
ALG_TYPE_EC_FP_PUBLIC
,
JCSystem
.
MEMORY_TYPE_TRANSIENT_RESET
,
KeyBuilder
.
LENGTH_EC_FP_256
,
false
);
ECPrivateKey
ecDhPriv
=
(
ECPrivateKey
)
KeyBuilder
.
buildKey
(
KeyBuilder
.
ALG_TYPE_EC_FP_PRIVATE
,
JCSystem
.
MEMORY_TYPE_TRANSIENT_RESET
,
KeyBuilder
.
LENGTH_EC_FP_256
,
false
);
ecDhKeyPair
=
new
KeyPair
(
ecDhPub
,
ecDhPriv
);
ecDhSet
=
JCSystem
.
makeTransientBooleanArray
((
short
)
1
,
JCSystem
.
CLEAR_ON_RESET
);
}
@Override
public
void
regenerate
()
{
}
@Override
public
void
resetPinUvAuthToken
()
{
}
@Override
public
byte
[]
getPublicKey
()
{
byte
[]
w
;
try
{
w
=
JCSystem
.
makeTransientByteArray
((
short
)
65
,
JCSystem
.
CLEAR_ON_RESET
);
}
catch
(
Exception
e
)
{
w
=
new
byte
[
65
];
}
if
(!
ecDhSet
[
0
])
{
// Grab the public key and set it's parameters
KeyParams
.
sec256r1params
((
ECKey
)
ecDhKeyPair
.
getPublic
());
// Generate a new key-pair
ecDhKeyPair
.
genKeyPair
();
ecDhSet
[
0
]
=
true
;
}
((
ECPublicKey
)
ecDhKeyPair
.
getPublic
()).
getW
(
w
,
(
short
)
0
);
// Return the data requested
return
w
;
}
public
byte
[]
encapsulate
(
COSEKey
peerCOSEKey
){
return
null
;
}
@Override
public
byte
[]
decapsulate
(
COSEKey
peerCOSEKey
)
{
return
null
;
}
public
byte
[]
encrypt
(
byte
[]
key
,
byte
[]
plaintext
){
return
null
;
}
@Override
public
void
decrypt
(
byte
[]
sharedSecret
,
byte
[]
cipherText
)
{
}
public
byte
[]
authenticate
(
byte
[]
key
,
byte
[]
message
){
return
null
;
}
@Override
public
void
verify
(
byte
[]
key
,
byte
[]
message
,
byte
[]
signature
)
{
}
private
byte
[]
ecdh
(
COSEKey
peerCoseKey
){
return
null
;
}
private
byte
[]
kdf
(
byte
[]
Z
){
return
null
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/josh/vku2f/PinUvAuthToken.java
0 → 100644
View file @
ba3ad98f
package
com.josh.vku2f
;
public
class
PinUvAuthToken
{
private
byte
[]
token
;
private
byte
protocol
;
private
byte
permissionsRPID
;
private
byte
permissionsSet
;
private
byte
usageTimer
;
private
boolean
inUseFlag
;
private
byte
initialUsageTimeLimit
;
private
byte
userPresentTimeLimit
;
private
byte
maxUsageTimePeriod
;
private
boolean
userVerifiedFlag
;
private
boolean
userPresentFlag
;
PinUvAuthToken
(){
resetTokenState
();
}
public
void
generateNewToken
(){
}
public
void
resetTokenState
(){
permissionsRPID
=
0x00
;
permissionsSet
=
0x00
;
usageTimer
=
0x00
;
inUseFlag
=
false
;
initialUsageTimeLimit
=
0x00
;
userPresentTimeLimit
=
0x00
;
maxUsageTimePeriod
=
0x00
;
userVerifiedFlag
=
false
;
userPresentFlag
=
false
;
}
public
boolean
isInUse
(){
return
inUseFlag
;
}
}
This diff is collapsed.
Click to expand it.
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