Skip to content

Commit 73edeec

Browse files
author
marinthiercelin
authored
Merge pull request #33 from ProtonMail/fix/incompatible-time-api
Remove usage of new time API
2 parents cb63915 + 1fd0956 commit 73edeec

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog for SRP
22

3+
## v0.0.5 (2022-05-10)
4+
5+
### Fixed
6+
7+
- Removed usage of time API that were incompatible with golang < 1.17
8+
39
## v0.0.4 (2022-05-05)
410

511
### Added

challenge.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ func (deadlineExceededError) Temporary() bool { return true }
2525

2626
const ecdlpPRFKeySize = 32
2727

28+
func unixMilli(currentTime time.Time) int64 {
29+
return currentTime.UnixNano() / 1e6
30+
}
31+
2832
// ECDLPChallenge computes the base64 solution for a given ECDLP base64 challenge
2933
// within deadlineUnixMilli milliseconds, if any was found. Deadlines are measured on the
3034
// wall clock, not the monotonic clock, due to unreliability on mobile devices.
@@ -43,7 +47,7 @@ func ECDLPChallenge(b64Challenge string, deadlineUnixMilli uint64) (b64Solution
4347
buffer := make([]byte, 8)
4448

4549
for i = 0;; i++ {
46-
if deadlineUnixMilli <= math.MaxInt64 && time.Now().UnixMilli() > int64(deadlineUnixMilli) {
50+
if deadlineUnixMilli <= math.MaxInt64 && unixMilli(time.Now()) > int64(deadlineUnixMilli) {
4751
return "", DeadlineExceeded
4852
}
4953

@@ -97,7 +101,7 @@ func Argon2PreimageChallenge(b64Challenge string, deadlineUnixMilli uint64) (b64
97101
buffer := make([]byte, 8)
98102

99103
for i = 0;; i++ {
100-
if deadlineUnixMilli <= math.MaxInt64 && time.Now().UnixMilli() > int64(deadlineUnixMilli) {
104+
if deadlineUnixMilli <= math.MaxInt64 && unixMilli(time.Now()) > int64(deadlineUnixMilli) {
101105
return "", DeadlineExceeded
102106
}
103107

version.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
package srp
2424

25-
const Version string = "0.0.4"
25+
const Version string = "0.0.5"
2626

27-
//VersionNumber get current libaray version
27+
// VersionNumber get current library version
2828
func VersionNumber() string {
2929
return Version
3030
}

0 commit comments

Comments
 (0)