Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
03678f74
Commit
03678f74
authored
Nov 04, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt-ify asn1
R=rsc
http://go/go-review/1018047
parent
517ebbb2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
23 deletions
+23
-23
src/pkg/asn1/asn1.go
src/pkg/asn1/asn1.go
+21
-21
src/pkg/asn1/asn1_test.go
src/pkg/asn1/asn1_test.go
+2
-2
No files found.
src/pkg/asn1/asn1.go
View file @
03678f74
...
@@ -110,9 +110,9 @@ func (b BitString) At(i int) int {
...
@@ -110,9 +110,9 @@ func (b BitString) At(i int) int {
if
i
<
0
||
i
>=
b
.
BitLength
{
if
i
<
0
||
i
>=
b
.
BitLength
{
return
0
;
return
0
;
}
}
x
:=
i
/
8
;
x
:=
i
/
8
;
y
:=
7
-
uint
(
i
%
8
);
y
:=
7
-
uint
(
i
%
8
);
return
int
(
b
.
Bytes
[
x
]
>>
y
)
&
1
;
return
int
(
b
.
Bytes
[
x
]
>>
y
)
&
1
;
}
}
// parseBitString parses an ASN.1 bit string from the given byte array and returns it.
// parseBitString parses an ASN.1 bit string from the given byte array and returns it.
...
@@ -124,7 +124,7 @@ func parseBitString(bytes []byte) (ret BitString, err os.Error) {
...
@@ -124,7 +124,7 @@ func parseBitString(bytes []byte) (ret BitString, err os.Error) {
paddingBits
:=
int
(
bytes
[
0
]);
paddingBits
:=
int
(
bytes
[
0
]);
if
paddingBits
>
7
||
if
paddingBits
>
7
||
len
(
bytes
)
==
1
&&
paddingBits
>
0
||
len
(
bytes
)
==
1
&&
paddingBits
>
0
||
bytes
[
len
(
bytes
)
-
1
]
&
((
1
<<
bytes
[
0
])
-
1
)
!=
0
{
bytes
[
len
(
bytes
)
-
1
]
&
((
1
<<
bytes
[
0
])
-
1
)
!=
0
{
err
=
SyntaxError
{
"invalid padding bits in BIT STRING"
};
err
=
SyntaxError
{
"invalid padding bits in BIT STRING"
};
return
;
return
;
}
}
...
@@ -152,8 +152,8 @@ func parseObjectIdentifier(bytes []byte) (s []int, err os.Error) {
...
@@ -152,8 +152,8 @@ func parseObjectIdentifier(bytes []byte) (s []int, err os.Error) {
s
=
make
([]
int
,
len
(
bytes
)
+
1
);
s
=
make
([]
int
,
len
(
bytes
)
+
1
);
// The first byte is 40*value1 + value2:
// The first byte is 40*value1 + value2:
s
[
0
]
=
int
(
bytes
[
0
])
/
40
;
s
[
0
]
=
int
(
bytes
[
0
])
/
40
;
s
[
1
]
=
int
(
bytes
[
0
])
%
40
;
s
[
1
]
=
int
(
bytes
[
0
])
%
40
;
i
:=
2
;
i
:=
2
;
for
offset
:=
1
;
offset
<
len
(
bytes
);
i
++
{
for
offset
:=
1
;
offset
<
len
(
bytes
);
i
++
{
var
v
int
;
var
v
int
;
...
@@ -201,7 +201,7 @@ func twoDigits(bytes []byte, max int) (int, bool) {
...
@@ -201,7 +201,7 @@ func twoDigits(bytes []byte, max int) (int, bool) {
return
0
,
false
;
return
0
,
false
;
}
}
}
}
value
:=
(
int
(
bytes
[
0
])
-
'0'
)
*
10
+
int
(
bytes
[
1
]
-
'0'
);
value
:=
(
int
(
bytes
[
0
])
-
'0'
)
*
10
+
int
(
bytes
[
1
]
-
'0'
);
if
value
>
max
{
if
value
>
max
{
return
0
,
false
;
return
0
,
false
;
}
}
...
@@ -459,8 +459,8 @@ type fieldParameters struct {
...
@@ -459,8 +459,8 @@ type fieldParameters struct {
defaultValue
*
int64
;
// a default value for INTEGER typed fields (maybe nil).
defaultValue
*
int64
;
// a default value for INTEGER typed fields (maybe nil).
tag
*
int
;
// the EXPLICIT or IMPLICIT tag (maybe nil).
tag
*
int
;
// the EXPLICIT or IMPLICIT tag (maybe nil).
// Invariants:
// Invariants:
// if explicit is set, tag is non-nil.
// if explicit is set, tag is non-nil.
}
}
// Given a tag string with the format specified in the package comment,
// Given a tag string with the format specified in the package comment,
...
...
src/pkg/asn1/asn1_test.go
View file @
03678f74
...
@@ -255,7 +255,7 @@ var unmarshalTestData []unmarshalTest = []unmarshalTest{
...
@@ -255,7 +255,7 @@ var unmarshalTestData []unmarshalTest = []unmarshalTest{
unmarshalTest
{[]
byte
{
0x16
,
0x04
,
't'
,
'e'
,
's'
,
't'
},
&
RawValue
{
0
,
22
,
false
,
[]
byte
{
't'
,
'e'
,
's'
,
't'
}}},
unmarshalTest
{[]
byte
{
0x16
,
0x04
,
't'
,
'e'
,
's'
,
't'
},
&
RawValue
{
0
,
22
,
false
,
[]
byte
{
't'
,
'e'
,
's'
,
't'
}}},
unmarshalTest
{[]
byte
{
0x04
,
0x04
,
1
,
2
,
3
,
4
},
&
RawValue
{
0
,
4
,
false
,
[]
byte
{
1
,
2
,
3
,
4
}}},
unmarshalTest
{[]
byte
{
0x04
,
0x04
,
1
,
2
,
3
,
4
},
&
RawValue
{
0
,
4
,
false
,
[]
byte
{
1
,
2
,
3
,
4
}}},
unmarshalTest
{[]
byte
{
0x30
,
0x03
,
0x81
,
0x01
,
0x01
},
&
TestContextSpecificTags
{
1
}},
unmarshalTest
{[]
byte
{
0x30
,
0x03
,
0x81
,
0x01
,
0x01
},
&
TestContextSpecificTags
{
1
}},
unmarshalTest
{[]
byte
{
0x30
,
0x08
,
0xa1
,
0x03
,
0x02
,
0x01
,
0x01
,
0x02
,
0x01
,
0x02
},
&
TestContextSpecificTags2
{
1
,
2
}},
unmarshalTest
{[]
byte
{
0x30
,
0x08
,
0xa1
,
0x03
,
0x02
,
0x01
,
0x01
,
0x02
,
0x01
,
0x02
},
&
TestContextSpecificTags2
{
1
,
2
}},
unmarshalTest
{[]
byte
{
0x01
,
0x01
,
0x00
},
newBool
(
false
)},
unmarshalTest
{[]
byte
{
0x01
,
0x01
,
0x00
},
newBool
(
false
)},
unmarshalTest
{[]
byte
{
0x01
,
0x01
,
0x01
},
newBool
(
true
)},
unmarshalTest
{[]
byte
{
0x01
,
0x01
,
0x01
},
newBool
(
true
)},
}
}
...
...
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