Skip to content

Commit ce463ca

Browse files
committed
nilaway: ipn_pipkeygen.go
1 parent a58718a commit ce463ca

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

intra/backend/ipn_pipkeygen.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ const (
3636
hashfn = crypto.SHA384 // 48 byte hash fn for RSA-PSS
3737
)
3838

39-
var errEmptyPipKeyState = errors.New("pipkey: empty pip key state")
39+
var (
40+
errEmptyPipKeyState = errors.New("pipkey: empty pip key state")
41+
errTokenCreat = errors.New("pipkey: cannot create token")
42+
)
4043

4144
type PipKeyProvider interface {
4245
// Blind generates id:blindMsg:blindingFactor:salt:msg
@@ -352,9 +355,12 @@ func (k *pkgen) finalize(blindSig string) (*PipKey, error) {
352355
}
353356

354357
// Token gnerates a 32 byte random as hex (auths dataplane ops)
355-
func Token() *PipToken {
356-
tok := PipToken(*StrOf(token()))
357-
return &tok
358+
func Token() (*PipToken, error) {
359+
if tokstr := StrOf(token()); tokstr != nil && tokstr.Len() > 0 {
360+
tok := PipToken(*tokstr)
361+
return &tok, nil
362+
}
363+
return nil, errTokenCreat
358364
}
359365

360366
func token() string {

0 commit comments

Comments
 (0)