github.com/jcmturner/gokrb5/v8@v8.4.4/pac/signature_data_test.go (about) 1 package pac 2 3 import ( 4 "encoding/hex" 5 "testing" 6 7 "github.com/jcmturner/gokrb5/v8/iana/chksumtype" 8 "github.com/jcmturner/gokrb5/v8/test/testdata" 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestPAC_SignatureData_Unmarshal_Server_Signature(t *testing.T) { 13 t.Parallel() 14 b, err := hex.DecodeString(testdata.MarshaledPAC_Server_Signature) 15 if err != nil { 16 t.Fatal("Could not decode test data hex string") 17 } 18 var k SignatureData 19 bz, err := k.Unmarshal(b) 20 if err != nil { 21 t.Fatalf("Error unmarshaling test data: %v", err) 22 } 23 sig, _ := hex.DecodeString("1e251d98d552be7df384f550") 24 zeroed, _ := hex.DecodeString("10000000000000000000000000000000") 25 assert.Equal(t, uint32(chksumtype.HMAC_SHA1_96_AES256), k.SignatureType, "Server signature type not as expected") 26 assert.Equal(t, sig, k.Signature, "Server signature not as expected") 27 assert.Equal(t, uint16(0), k.RODCIdentifier, "RODC Identifier not as expected") 28 assert.Equal(t, zeroed, bz, "Returned bytes with zeroed signature not as expected") 29 } 30 31 func TestPAC_SignatureData_Unmarshal_KDC_Signature(t *testing.T) { 32 t.Parallel() 33 b, err := hex.DecodeString(testdata.MarshaledPAC_KDC_Signature) 34 if err != nil { 35 t.Fatal("Could not decode test data hex string") 36 } 37 var k SignatureData 38 bz, err := k.Unmarshal(b) 39 if err != nil { 40 t.Fatalf("Error unmarshaling test data: %v", err) 41 } 42 sig, _ := hex.DecodeString("340be28b48765d0519ee9346cf53d822") 43 zeroed, _ := hex.DecodeString("76ffffff00000000000000000000000000000000") 44 assert.Equal(t, chksumtype.KERB_CHECKSUM_HMAC_MD5_UNSIGNED, k.SignatureType, "Server signature type not as expected") 45 assert.Equal(t, sig, k.Signature, "Server signature not as expected") 46 assert.Equal(t, uint16(0), k.RODCIdentifier, "RODC Identifier not as expected") 47 assert.Equal(t, zeroed, bz, "Returned bytes with zeroed signature not as expected") 48 }