|
|
@@ -10,10 +10,15 @@ import (
|
|
|
)
|
|
|
|
|
|
// RFC 3961: DR(Key, Constant) = k-truncate(E(Key, Constant, initial-cipher-state)).
|
|
|
+//
|
|
|
// key: base key or protocol key. Likely to be a key from a keytab file.
|
|
|
+//
|
|
|
// usage: a constant.
|
|
|
+//
|
|
|
// n: block size in bits (not bytes) - note if you use something like aes.BlockSize this is in bytes.
|
|
|
+//
|
|
|
// k: key length / key seed length in bits. Eg. for AES256 this value is 256.
|
|
|
+//
|
|
|
// e: the encryption etype function to use.
|
|
|
func DeriveRandom(key, usage []byte, n, k int, e etype.EType) ([]byte, error) {
|
|
|
//Ensure the usage constant is at least the size of the cypher block size. Pass it through the nfold algorithm that will "stretch" it if needs be.
|
|
|
@@ -145,21 +150,27 @@ func VerifyChecksum(key, chksum, msg []byte, usage uint32, etype etype.EType) bo
|
|
|
}
|
|
|
|
|
|
// Get the checksum key usage value for the usage number un.
|
|
|
+//
|
|
|
// RFC 3961: The "well-known constant" used for the DK function is the key usage number, expressed as four octets in big-endian order, followed by one octet indicated below.
|
|
|
+//
|
|
|
// Kc = DK(base-key, usage | 0x99);
|
|
|
func GetUsageKc(un uint32) []byte {
|
|
|
return getUsage(un, 0x99)
|
|
|
}
|
|
|
|
|
|
// Get the encryption key usage value for the usage number un
|
|
|
+//
|
|
|
// RFC 3961: The "well-known constant" used for the DK function is the key usage number, expressed as four octets in big-endian order, followed by one octet indicated below.
|
|
|
+//
|
|
|
// Ke = DK(base-key, usage | 0xAA);
|
|
|
func GetUsageKe(un uint32) []byte {
|
|
|
return getUsage(un, 0xAA)
|
|
|
}
|
|
|
|
|
|
// Get the integrity key usage value for the usage number un
|
|
|
+//
|
|
|
// RFC 3961: The "well-known constant" used for the DK function is the key usage number, expressed as four octets in big-endian order, followed by one octet indicated below.
|
|
|
+//
|
|
|
// Ki = DK(base-key, usage | 0x55);
|
|
|
func GetUsageKi(un uint32) []byte {
|
|
|
return getUsage(un, 0x55)
|