mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-14 02:41:34 +01:00
41 lines
512 B
Go
41 lines
512 B
Go
|
package v2
|
||
|
|
||
|
import (
|
||
|
"crypto/sha256"
|
||
|
"hash"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
AuthAlgoUnknown AuthAlgo = iota
|
||
|
AuthAlgoHMACSHA256
|
||
|
)
|
||
|
|
||
|
type AuthAlgo uint8
|
||
|
|
||
|
func (a AuthAlgo) String() string {
|
||
|
switch a {
|
||
|
case AuthAlgoHMACSHA256:
|
||
|
return "HMAC-SHA256"
|
||
|
default:
|
||
|
return "Unknown"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a AuthAlgo) New() func() hash.Hash {
|
||
|
switch a {
|
||
|
case AuthAlgoHMACSHA256:
|
||
|
return sha256.New
|
||
|
default:
|
||
|
return nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a AuthAlgo) Size() int {
|
||
|
switch a {
|
||
|
case AuthAlgoHMACSHA256:
|
||
|
return sha256.Size
|
||
|
default:
|
||
|
return 0
|
||
|
}
|
||
|
}
|