Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Switch to short date, less b64 in returned SMS signature #1722

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/signatures/sms.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func SignSMS(signer crypto.Signer, keyID string, t time.Time, purpose SMSPurpose
return "", fmt.Errorf("failed to sign sms: %w", err)
}

date := t.Format(project.RFC3339Date)
return newBody + b64([]byte(date)) + colon + b64([]byte(keyID)) + colon + b64(sig), nil
date := t.Format("0102")
return newBody + date + colon + keyID + colon + b64(sig), nil
}

// smsSignatureString builds the string that is to be signed. The provided date
Expand Down
15 changes: 3 additions & 12 deletions pkg/signatures/sms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,13 @@ func Test_SMSSignature(t *testing.T) {
}
case 1:
// Next is date
b, err := base64.RawStdEncoding.DecodeString(part)
if err != nil {
t.Fatal(err)
}

date := tc.time.UTC().Format("2006-01-02")
if got, want := string(b), date; got != want {
date := tc.time.UTC().Format("0102")
if got, want := part, date; got != want {
t.Errorf("expected %q to be %q", got, want)
}
case 2:
// Next is key id
b, err := base64.RawStdEncoding.DecodeString(part)
if err != nil {
t.Fatal(err)
}
if got, want := string(b), tc.keyID; got != want {
if got, want := part, tc.keyID; got != want {
t.Errorf("expected %q to be %q", got, want)
}
case 3:
Expand Down