Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PassportApplet
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
PassportApplet
Commits
880b40ed
Commit
880b40ed
authored
Aug 08, 2022
by
Josh Ji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code review, rename project
parent
46acfc73
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
46 deletions
+47
-46
.gitignore
.gitignore
+2
-1
settings.gradle
settings.gradle
+1
-1
src/main/java/josh/passport/CVCertificate.java
src/main/java/josh/passport/CVCertificate.java
+44
-44
No files found.
.gitignore
View file @
880b40ed
# Project exclude paths
/.gradle/
/build/
/.idea/
settings.gradle
View file @
880b40ed
rootProject
.
name
=
'
p
assportApplet'
rootProject
.
name
=
'
P
assportApplet'
src/main/java/josh/passport/CVCertificate.java
View file @
880b40ed
...
...
@@ -20,7 +20,7 @@ public class CVCertificate {
private
static
final
byte
ROLE_DV_FOREIGN
=
(
byte
)
0x40
;
private
static
final
byte
ACCESS_DG3
=
0x01
;
private
static
final
byte
ACCESS_DG4
=
0x02
;
private
static
final
byte
CAR_TAG
=
0x42
;
private
static
final
byte
CAR_TAG
=
0x42
;
// Certificate Authority file reference tag
/**
...
...
@@ -311,7 +311,7 @@ public class CVCertificate {
*
* @param num certificate number, 1 or 2.
*/
void
setRootCertificate
(
byte
[]
in
,
short
num
)
{
void
setRootCertificate
(
byte
[]
in
put
,
short
num
)
{
if
((
num
==
1
&&
cert1HolderReference
!=
null
)
||
(
num
==
2
&&
cert2HolderReference
!=
null
)
||
(
num
!=
1
&&
num
!=
2
))
{
return
;
}
...
...
@@ -325,16 +325,16 @@ public class CVCertificate {
short
effDateOffset
=
data
[
OFFSET_EFF_DATE_OFFSET
];
short
expDateOffset
=
data
[
OFFSET_EXP_DATE_OFFSET
];
byte
[]
holderReference
=
new
byte
[
17
];
Util
.
arrayCopyNonAtomic
(
in
,
certHolderReferenceOffset
,
holderReference
,
(
short
)
1
,
certHolderReferenceLength
);
Util
.
arrayCopyNonAtomic
(
in
put
,
certHolderReferenceOffset
,
holderReference
,
(
short
)
1
,
certHolderReferenceLength
);
holderReference
[
0
]
=
(
byte
)
certHolderReferenceLength
;
byte
[]
certPubKeyData
=
new
byte
[(
short
)(
pubKeyExpLength
+
pubKeyModLength
)];
Util
.
arrayCopyNonAtomic
(
in
,
pubKeyExpOffset
,
certPubKeyData
,
(
short
)
0
,
pubKeyExpLength
);
Util
.
arrayCopyNonAtomic
(
in
,
pubKeyModOffset
,
certPubKeyData
,
pubKeyExpLength
,
pubKeyModLength
);
byte
certAuthorization
=
in
[
authorizationOffset
];
Util
.
arrayCopyNonAtomic
(
in
put
,
pubKeyExpOffset
,
certPubKeyData
,
(
short
)
0
,
pubKeyExpLength
);
Util
.
arrayCopyNonAtomic
(
in
put
,
pubKeyModOffset
,
certPubKeyData
,
pubKeyExpLength
,
pubKeyModLength
);
byte
certAuthorization
=
in
put
[
authorizationOffset
];
byte
[]
certEffDate
=
new
byte
[
6
];
Util
.
arrayCopyNonAtomic
(
in
,
effDateOffset
,
certEffDate
,
(
short
)
0
,
(
short
)
6
);
Util
.
arrayCopyNonAtomic
(
in
put
,
effDateOffset
,
certEffDate
,
(
short
)
0
,
(
short
)
6
);
byte
[]
certExpDate
=
new
byte
[
6
];
Util
.
arrayCopyNonAtomic
(
in
,
expDateOffset
,
certExpDate
,
(
short
)
0
,
(
short
)
6
);
Util
.
arrayCopyNonAtomic
(
in
put
,
expDateOffset
,
certExpDate
,
(
short
)
0
,
(
short
)
6
);
if
(
num
==
1
)
{
cert1HolderReference
=
holderReference
;
cert1PublicKeyData
=
certPubKeyData
;
...
...
@@ -358,7 +358,7 @@ public class CVCertificate {
* parse the signature (we have chosen not to provide it). The format of the
* certificate is described in EAC spec version 1.11 App A & C.
*
* @param in
* @param in
put
* the array with the certificate to be parsed
* @param offset
* offset to in
...
...
@@ -367,99 +367,99 @@ public class CVCertificate {
* @param root
* whether we are parsing a root certificate (no signature)
*/
void
parseCertificate
(
byte
[]
in
,
short
offset
,
short
length
,
boolean
root
)
{
void
parseCertificate
(
byte
[]
in
put
,
short
offset
,
short
length
,
boolean
root
)
{
try
{
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_CERT_BODY
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
offset
=
BERTLVScanner
.
readLength
(
in
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_CERT_VERSION
||
BERTLVScanner
.
valueLength
!=
(
short
)
1
||
in
[
offset
]
!=
(
byte
)
0x00
)
{
||
in
put
[
offset
]
!=
(
byte
)
0x00
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
offset
=
BERTLVScanner
.
skipValue
();
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_AUTH_ID
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
BERTLVScanner
.
readLength
(
in
,
offset
);
BERTLVScanner
.
readLength
(
in
put
,
offset
);
offset
=
BERTLVScanner
.
skipValue
();
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_PUB_KEY
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
offset
=
BERTLVScanner
.
readLength
(
in
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_OID
||
BERTLVScanner
.
valueLength
!=
(
short
)
RSA_SHA1_OID
.
length
||
Util
.
arrayCompare
(
in
,
offset
,
RSA_SHA1_OID
,
(
short
)
0
,
||
Util
.
arrayCompare
(
in
put
,
offset
,
RSA_SHA1_OID
,
(
short
)
0
,
(
short
)
RSA_SHA1_OID
.
length
)
!=
0
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
offset
=
BERTLVScanner
.
skipValue
();
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_MODULUS
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
data
[
OFFSET_PUB_KEY_MODULUS_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
,
data
[
OFFSET_PUB_KEY_MODULUS_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
data
[
OFFSET_PUB_KEY_MODULUS_LENGTH
]
=
BERTLVScanner
.
valueLength
;
offset
=
BERTLVScanner
.
skipValue
();
if
(
in
[
data
[
OFFSET_PUB_KEY_MODULUS_OFFSET
]]
==
(
byte
)
0x00
)
{
if
(
in
put
[
data
[
OFFSET_PUB_KEY_MODULUS_OFFSET
]]
==
(
byte
)
0x00
)
{
data
[
OFFSET_PUB_KEY_MODULUS_OFFSET
]++;
data
[
OFFSET_PUB_KEY_MODULUS_LENGTH
]--;
}
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_EXPONENT
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
data
[
OFFSET_PUB_KEY_EXPONENT_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
,
data
[
OFFSET_PUB_KEY_EXPONENT_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
data
[
OFFSET_PUB_KEY_EXPONENT_LENGTH
]
=
BERTLVScanner
.
valueLength
;
offset
=
BERTLVScanner
.
skipValue
();
if
(
in
[
data
[
OFFSET_PUB_KEY_EXPONENT_OFFSET
]]
==
(
byte
)
0x00
)
{
if
(
in
put
[
data
[
OFFSET_PUB_KEY_EXPONENT_OFFSET
]]
==
(
byte
)
0x00
)
{
data
[
OFFSET_PUB_KEY_EXPONENT_OFFSET
]++;
data
[
OFFSET_PUB_KEY_EXPONENT_LENGTH
]--;
}
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_SUBJECT_ID
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
data
[
OFFSET_SUB_ID_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
,
offset
);
data
[
OFFSET_SUB_ID_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
data
[
OFFSET_SUB_ID_LENGTH
]
=
BERTLVScanner
.
valueLength
;
offset
=
BERTLVScanner
.
skipValue
();
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_SUBJECT_AUTH
||
BERTLVScanner
.
valueLength
!=
(
short
)
14
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
offset
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_OID
||
BERTLVScanner
.
valueLength
!=
(
short
)
EAC_OID
.
length
||
Util
.
arrayCompare
(
in
,
offset
,
EAC_OID
,
||
Util
.
arrayCompare
(
in
put
,
offset
,
EAC_OID
,
(
short
)
0
,
(
short
)
EAC_OID
.
length
)
!=
0
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
offset
=
BERTLVScanner
.
skipValue
();
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
data
[
OFFSET_AUTHORIZATION_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
,
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
data
[
OFFSET_AUTHORIZATION_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_AUTHORIZATION
||
BERTLVScanner
.
valueLength
!=
(
short
)
1
)
{
...
...
@@ -467,16 +467,16 @@ public class CVCertificate {
}
offset
=
BERTLVScanner
.
skipValue
();
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
data
[
OFFSET_EFF_DATE_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
data
[
OFFSET_EFF_DATE_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_EFF_DATE
||
BERTLVScanner
.
valueLength
!=
(
short
)
6
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
offset
=
BERTLVScanner
.
skipValue
();
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
data
[
OFFSET_EXP_DATE_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
data
[
OFFSET_EXP_DATE_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_EXP_DATE
||
BERTLVScanner
.
valueLength
!=
(
short
)
6
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
...
...
@@ -484,14 +484,14 @@ public class CVCertificate {
offset
=
BERTLVScanner
.
skipValue
();
data
[
OFFSET_BODY_LENGTH
]
=
offset
;
if
(!
root
)
{
offset
=
BERTLVScanner
.
readTag
(
in
,
offset
);
offset
=
BERTLVScanner
.
readTag
(
in
put
,
offset
);
if
(
BERTLVScanner
.
tag
!=
TAG_SIGNATURE
)
{
ISOException
.
throwIt
(
ISO7816
.
SW_WRONG_DATA
);
}
data
[
OFFSET_SIGNATURE_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
,
data
[
OFFSET_SIGNATURE_OFFSET
]
=
BERTLVScanner
.
readLength
(
in
put
,
offset
);
data
[
OFFSET_SIGNATURE_LENGTH
]
=
BERTLVScanner
.
valueLength
;
source
[
0
]
=
in
;
source
[
0
]
=
in
put
;
}
}
catch
(
Exception
e
){
clear
();
...
...
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