diff --git a/auth/callback.go b/auth/callback.go index a437d834ccc7240cdcc5ee18ee85528c6fc99d8a..2ae9446f1e6826a867c89b1243eb96a2cefd5aa8 100644 --- a/auth/callback.go +++ b/auth/callback.go @@ -531,7 +531,7 @@ func handleBaseFormat(cmixMsg format.Message, grp *cyclic.Group) (baseFormat, baseFmt, err := unmarshalBaseFormat(cmixMsg.GetContents(), grp.GetP().ByteLen()) - if err != nil { + if err != nil && baseFmt == nil { return baseFormat{}, nil, errors.WithMessage(err, "Failed to"+ " unmarshal auth") } @@ -542,5 +542,5 @@ func handleBaseFormat(cmixMsg format.Message, grp *cyclic.Group) (baseFormat, } partnerPubKey := grp.NewIntFromBytes(baseFmt.pubkey) - return baseFmt, partnerPubKey, nil + return *baseFmt, partnerPubKey, nil } diff --git a/auth/fmt.go b/auth/fmt.go index f267945be7934705f7046b948efc409c42f51d6d..cf38aaed44967d8a825a27451783bf5318038544 100644 --- a/auth/fmt.go +++ b/auth/fmt.go @@ -65,18 +65,18 @@ func buildBaseFormat(data []byte, pubkeySize int) baseFormat { return f } -func unmarshalBaseFormat(b []byte, pubkeySize int) (baseFormat, error) { +func unmarshalBaseFormat(b []byte, pubkeySize int) (*baseFormat, error) { if len(b) < pubkeySize { - return baseFormat{}, errors.New("Received baseFormat too small") + return nil, errors.New("Received baseFormat too small") } bfmt := buildBaseFormat(b, pubkeySize) version := bfmt.GetVersion() if version != requestFmtVersion { - return baseFormat{}, errors.Errorf( + return &bfmt, errors.Errorf( "Unknown baseFormat version: %d", version) } - return bfmt, nil + return &bfmt, nil } func (f baseFormat) Marshal() []byte { diff --git a/auth/fmt_test.go b/auth/fmt_test.go index 64785b399abc261400a346fceb68bc4ee0fc59c0..30580ec1bef400eb05409d3033076e9f0b00b4cd 100644 --- a/auth/fmt_test.go +++ b/auth/fmt_test.go @@ -151,10 +151,10 @@ func TestBaseFormat_MarshalUnmarshal(t *testing.T) { "Could not unmarshal into baseFormat: %v", err) } - if !reflect.DeepEqual(newMsg, baseMsg) { + if !reflect.DeepEqual(*newMsg, baseMsg) { t.Errorf("unmarshalBaseFormat() error: "+ "Unmarshalled message does not match originally marshalled message."+ - "\n\tExpected: %v\n\tRecieved: %v", baseMsg, newMsg) + "\n\tExpected: %v\n\tRecieved: %v", baseMsg, *newMsg) } // Unmarshal error test: Invalid size parameter