-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1116 from ersonp/refactor/internal
Refactor internal packages
- Loading branch information
Showing
8 changed files
with
50 additions
and
269 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package httpauth | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/skycoin/dmsg/cipher" | ||
) | ||
|
||
// Nonce is used to sign requests in order to avoid replay attack | ||
type Nonce uint64 | ||
|
||
func (n Nonce) String() string { return fmt.Sprintf("%d", n) } | ||
|
||
// PayloadWithNonce returns the concatenation of payload and nonce. | ||
func PayloadWithNonce(payload []byte, nonce Nonce) []byte { | ||
return []byte(fmt.Sprintf("%s%d", string(payload), nonce)) | ||
} | ||
|
||
// Sign signs the Hash of payload and nonce | ||
func Sign(payload []byte, nonce Nonce, sec cipher.SecKey) (cipher.Sig, error) { | ||
return cipher.SignPayload(PayloadWithNonce(payload, nonce), sec) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.