expose macsequal
This commit is contained in:
		
							parent
							
								
									1da4ab53b9
								
							
						
					
					
						commit
						1010dbd7d2
					
				| @ -36,7 +36,7 @@ func zeroPaddedBytes(bytes []byte, offset int, size int) []byte { | ||||
| 	return newSlice | ||||
| } | ||||
| 
 | ||||
| func macsEqual(slice1, slice2 []byte) bool { | ||||
| func MacsEqual(slice1, slice2 []byte) bool { | ||||
| 	if len(slice1) != len(slice2) { | ||||
| 		return false | ||||
| 	} | ||||
|  | ||||
| @ -15,19 +15,19 @@ func TestUTf16ToString(t *testing.T) { | ||||
| } | ||||
| 
 | ||||
| func TestMacsEquals(t *testing.T) { | ||||
| 	// the macsEqual should ignore the values in the second 4 bytes | ||||
| 	// the MacsEqual should ignore the values in the second 4 bytes | ||||
| 	firstSlice := []byte{0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xf0, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff} | ||||
| 	secondSlice := []byte{0xf1, 0xf2, 0xf3, 0xf4, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf0, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff} | ||||
| 	if !macsEqual(firstSlice, secondSlice) { | ||||
| 		t.Errorf("Expected macsEqual(%v, %v) to be true", firstSlice, secondSlice) | ||||
| 	if !MacsEqual(firstSlice, secondSlice) { | ||||
| 		t.Errorf("Expected MacsEqual(%v, %v) to be true", firstSlice, secondSlice) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestMacsEqualsFail(t *testing.T) { | ||||
| 	// the last bytes in the following test case should cause macsEqual to return false | ||||
| 	// the last bytes in the following test case should cause MacsEqual to return false | ||||
| 	firstSlice := []byte{0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xf0, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff} | ||||
| 	secondSlice := []byte{0xf1, 0xf2, 0xf3, 0xf4, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf0, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xfe} | ||||
| 	if macsEqual(firstSlice, secondSlice) { | ||||
| 		t.Errorf("Expected macsEqual(%v, %v) to be false", firstSlice, secondSlice) | ||||
| 	if MacsEqual(firstSlice, secondSlice) { | ||||
| 		t.Errorf("Expected MacsEqual(%v, %v) to be false", firstSlice, secondSlice) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -138,12 +138,12 @@ func (n *V1ClientSession) Mac(message []byte, sequenceNumber int) ([]byte, error | ||||
| 
 | ||||
| func (n *V1ServerSession) VerifyMac(message, expectedMac []byte, sequenceNumber int) (bool, error) { | ||||
| 	mac := ntlmV1Mac(message, sequenceNumber, n.clientHandle, n.ClientSealingKey, n.ClientSigningKey, n.NegotiateFlags) | ||||
| 	return macsEqual(mac, expectedMac), nil | ||||
| 	return MacsEqual(mac, expectedMac), nil | ||||
| } | ||||
| 
 | ||||
| func (n *V1ClientSession) VerifyMac(message, expectedMac []byte, sequenceNumber int) (bool, error) { | ||||
| 	mac := ntlmV1Mac(message, sequenceNumber, n.serverHandle, n.ServerSealingKey, n.ServerSigningKey, n.NegotiateFlags) | ||||
| 	return macsEqual(mac, expectedMac), nil | ||||
| 	return MacsEqual(mac, expectedMac), nil | ||||
| } | ||||
| 
 | ||||
| /************** | ||||
|  | ||||
| @ -124,7 +124,7 @@ func (n *V2ServerSession) Mac(message []byte, sequenceNumber int) ([]byte, error | ||||
| 
 | ||||
| func (n *V2ServerSession) VerifyMac(message, expectedMac []byte, sequenceNumber int) (bool, error) { | ||||
| 	mac := NtlmV2Mac(message, sequenceNumber, n.clientHandle, n.ClientSealingKey, n.ClientSigningKey, n.NegotiateFlags) | ||||
| 	return macsEqual(mac, expectedMac), nil | ||||
| 	return MacsEqual(mac, expectedMac), nil | ||||
| } | ||||
| 
 | ||||
| func (n *V2ClientSession) Mac(message []byte, sequenceNumber int) ([]byte, error) { | ||||
| @ -134,7 +134,7 @@ func (n *V2ClientSession) Mac(message []byte, sequenceNumber int) ([]byte, error | ||||
| 
 | ||||
| func (n *V2ClientSession) VerifyMac(message, expectedMac []byte, sequenceNumber int) (bool, error) { | ||||
| 	mac := NtlmV2Mac(message, sequenceNumber, n.serverHandle, n.ServerSealingKey, n.ServerSigningKey, n.NegotiateFlags) | ||||
| 	return macsEqual(mac, expectedMac), nil | ||||
| 	return MacsEqual(mac, expectedMac), nil | ||||
| } | ||||
| 
 | ||||
| /************** | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user