| 1 | // Copyright 2022 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package mactest_testscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/internal/mactest_test`/ |
| 16 | |
| 17 | import ( |
| 18 | "errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/" |
| 19 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 20 | |
| 21 | "github.com/tink-crypto/tink-go/v2/mac/internal/mactestscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/internal/mactest`/" |
| 22 | ) |
| 23 | |
| 24 | func TestAlwaysFailingMACAlwayFailsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/internal/mactest_test`/TestAlwaysFailingMACAlwayFails().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 25 | wantErr := errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/.Newscip-go gomod github.com/golang/go/src go1.24.0 errors/New().("panic at the kernel") |
| 26 | p := &mactestscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/internal/mactest`/.AlwaysFailingMACscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/internal/mactest`/AlwaysFailingMAC#{Errorscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/internal/mactest`/AlwaysFailingMAC#Error.: wantErr} |
| 27 | if _, err := p.ComputeMACscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/internal/mactest`/AlwaysFailingMAC#ComputeMAC().([]byte("valid_data")); !errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/.Isscip-go gomod github.com/golang/go/src go1.24.0 errors/Is().(err, wantErr) { |
| 28 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("p.ComputeMac() err = %v, want %v", err, wantErr) |
| 29 | } |
| 30 | if err := p.VerifyMACscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/internal/mactest`/AlwaysFailingMAC#VerifyMAC().([]byte("data"), []byte("tag")); !errorsscip-go gomod github.com/golang/go/src go1.24.0 errors/.Isscip-go gomod github.com/golang/go/src go1.24.0 errors/Is().(err, wantErr) { |
| 31 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("p.VerifyMac() err = %v, want %v", err, wantErr) |
| 32 | } |
| 33 | } |