github.com/jcmturner/gokrb5/v8@v8.4.4/crypto/rfc4757/msgtype.go (about)

     1  package rfc4757
     2  
     3  import "encoding/binary"
     4  
     5  // UsageToMSMsgType converts Kerberos key usage numbers to Microsoft message type encoded as a little-endian four byte slice.
     6  func UsageToMSMsgType(usage uint32) []byte {
     7  	// Translate usage numbers to the Microsoft T numbers
     8  	switch usage {
     9  	case 3:
    10  		usage = 8
    11  	case 9:
    12  		usage = 8
    13  	case 23:
    14  		usage = 13
    15  	}
    16  	// Now convert to bytes
    17  	tb := make([]byte, 4) // We force an int32 input so we can't go over 4 bytes
    18  	binary.PutUvarint(tb, uint64(usage))
    19  	return tb
    20  }