Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
Metrics
Library
Commits
82f555ee
Commit
82f555ee
authored
May 29, 2017
by
Karsten Loesing
Browse files
Fix encoding of Microdescriptor's getDigestSha256Base64().
parent
823fa496
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
82f555ee
...
...
@@ -5,6 +5,8 @@
and maps to avoid repeating string literals and to use more speedy
collection types.
-
Simplify and avoid repetition in parse helper methods.
-
Fix a bug where Microdescriptor's getDigestSha256Base64() returns
a hex string rather than a base64 string.
# Changes in version 1.7.0 - 2017-05-17
...
...
src/main/java/org/torproject/descriptor/impl/MicrodescriptorImpl.java
View file @
82f555ee
...
...
@@ -243,9 +243,9 @@ public class MicrodescriptorImpl extends DescriptorImpl
byte
[]
forDigest
=
new
byte
[
end
-
start
];
System
.
arraycopy
(
this
.
getRawDescriptorBytes
(),
start
,
forDigest
,
0
,
end
-
start
);
this
.
microdescriptorDigest
=
DatatypeConverter
.
print
Hex
Binary
(
this
.
microdescriptorDigest
=
DatatypeConverter
.
print
Base64
Binary
(
MessageDigest
.
getInstance
(
"SHA-256"
).
digest
(
forDigest
))
.
toLowerCase
(
);
.
replaceAll
(
"="
,
""
);
}
}
catch
(
UnsupportedEncodingException
e
)
{
/* Handle below. */
...
...
src/test/java/org/torproject/descriptor/impl/MicrodescriptorImplTest.java
View file @
82f555ee
...
...
@@ -3,6 +3,8 @@
package
org.torproject.descriptor.impl
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.torproject.descriptor.DescriptorParseException
;
import
org.torproject.descriptor.Microdescriptor
;
...
...
@@ -57,7 +59,9 @@ public class MicrodescriptorImplTest {
@Test
()
public
void
testDefaults
()
throws
DescriptorParseException
{
DescriptorBuilder
.
createWithDefaultLines
();
Microdescriptor
micro
=
DescriptorBuilder
.
createWithDefaultLines
();
assertEquals
(
"ER1AC4KqT//o3pJDrqlmej5G2qW1EQYEr/IrMQHNc6I"
,
micro
.
getDigestSha256Base64
());
}
@Test
(
expected
=
DescriptorParseException
.
class
)
...
...
Write
Preview
Supports
Markdown
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