Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
go-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai3
go-common
Commits
95125bd5
Commit
95125bd5
authored
6 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Fix the U2F serialization format
The encoded public key is actually 65 bytes long, not 64.
parent
f7e5788a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ldap/compositetypes/composite_types.go
+3
-3
3 additions, 3 deletions
ldap/compositetypes/composite_types.go
ldap/compositetypes/composite_types_test.go
+15
-2
15 additions, 2 deletions
ldap/compositetypes/composite_types_test.go
with
18 additions
and
5 deletions
ldap/compositetypes/composite_types.go
+
3
−
3
View file @
95125bd5
...
...
@@ -123,13 +123,13 @@ func (r *U2FRegistration) Marshal() string {
// UnmarshalU2FRegistration parses a U2FRegistration from its serialized format.
func
UnmarshalU2FRegistration
(
s
string
)
(
*
U2FRegistration
,
error
)
{
if
len
(
s
)
<
6
4
{
if
len
(
s
)
<
6
5
{
return
nil
,
errors
.
New
(
"badly encoded u2f registration"
)
}
b
:=
[]
byte
(
s
)
return
&
U2FRegistration
{
PublicKey
:
b
[
:
6
4
],
KeyHandle
:
b
[
6
4
:
],
PublicKey
:
b
[
:
6
5
],
KeyHandle
:
b
[
6
5
:
],
},
nil
}
...
...
This diff is collapsed.
Click to expand it.
ldap/compositetypes/composite_types_test.go
+
15
−
2
View file @
95125bd5
...
...
@@ -40,8 +40,8 @@ func TestEncryptedKey_Serialization(t *testing.T) {
func
TestU2FRegistration_Serialization
(
t
*
testing
.
T
)
{
key
:=
&
U2FRegistration
{
KeyHandle
:
[]
byte
(
"
\
x04\
xc8\x1d\xd3\x9e
~/
\xb8\xed
G(
\xcb\x82\xf1\x0f\xb5\xac\xd6\xaf
~
\xc7\xfa\xb8\x96
P
\x91\xec
J
\xa1
,TRF
\x88\xd1\x1a\xda
Q<
\xd8
-a
\xd7\xb0\xd9
v
\xd7\xe8
f
\x8e\xab\xf6\x10\x89
5
\xe6\x9f\xf3\x86
;
\xab\xc1\xae\x83
^"
),
PublicKey
:
[]
byte
(
"w'Ra
\xd8\x17\xdf\x86\x06\xb0\xd0\x8f\x0e
I
\x98\xd7\xc1\xf7\xb0
}j
\xc3\x1c
8
\xf0\x8f
h
\xcf\xe0\x84
W
\xc6\xa3\x1d\xc8
e/
\xa5
]v
\xfa
]
\xa5\xfb\xd5
c
\xbe\xc7
2
\xb9\x80\xa9\xc0
O
\xd1\xe5\x9d\xe0\xcd\x19
q@
\xeb
"
),
KeyHandle
:
[]
byte
(
"
\xc8\x1d\xd3\x9e
~/
\xb8\xed
G(
\xcb\x82\xf1\x0f\xb5\xac\xd6\xaf
~
\xc7\xfa\xb8\x96
P
\x91\xec
J
\xa1
,TRF
\x88\xd1\x1a\xda
Q<
\xd8
-a
\xd7\xb0\xd9
v
\xd7\xe8
f
\x8e\xab\xf6\x10\x89
5
\xe6\x9f\xf3\x86
;
\xab\xc1\xae\x83
^"
),
PublicKey
:
[]
byte
(
"w'Ra
\xd8\x17\xdf\x86\x06\xb0\xd0\x8f\x0e
I
\x98\xd7\xc1\xf7\xb0
}j
\xc3\x1c
8
\xf0\x8f
h
\xcf\xe0\x84
W
\xc6\xa3\x1d\xc8
e/
\xa5
]v
\xfa
]
\xa5\xfb\xd5
c
\xbe\xc7
2
\xb9\x80\xa9\xc0
O
\xd1\xe5\x9d\xe0\xcd\x19
q@
\xeb
\x04
"
),
}
out
,
err
:=
UnmarshalU2FRegistration
(
key
.
Marshal
())
...
...
@@ -52,3 +52,16 @@ func TestU2FRegistration_Serialization(t *testing.T) {
t
.
Fatalf
(
"result differs: %s"
,
diffs
)
}
}
func
TestU2FRegistration_Deserialization
(
t
*
testing
.
T
)
{
// Sample key, obtained via "accounts" -> "accountserver" -> db.
orig
:=
"
\x04\xe7
r
\x1a\x9b
%e5
\xb0\xa8
9
\xca
d9%
\xd1
wk
\x05
9
\xda
?
\xca\x13\xa3
`
\xa6
H
\x96
Q
\xa6\xa4
$
\x91
C
\xbf
2r.
\xa2\x1c
z
\xd2\xfc\xe4\xf9\x16\x02\x01\xb5\x04
~Z
\xf4\x02
j-
\xe1
8
\xd4
|+a;
\x96\x08
Wa
\xe2
sc9iu
\xfb\x87\xb2\x99\xd0\xd4\x88
!m
\x8f\x94\xf6\xf8\x1d
5
\xf1\x1c\x9b\xce\xfb
ud;fj
\x1b\x0f
G
\x8b\r\xa4\xae\xda
i
\x96
N
\x1b
d
\xb4\xff\xc0
_T
\x1f\xb3
p
\xdf
T
\xcb\x94\xc2\x0f
b}
\x1a
"
reg
,
err
:=
UnmarshalU2FRegistration
(
orig
)
if
err
!=
nil
{
t
.
Fatalf
(
"bad: %v"
,
err
)
}
if
_
,
err
:=
reg
.
Decode
();
err
!=
nil
{
t
.
Fatalf
(
"decode: %v"
,
err
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment