Documentation
¶
Index ¶
- Constants
- func WriteEntry(buffer *bytes.Buffer, entryType KeyCredentialEntryType, data []byte)
- type KeyCredential
- func (kc *KeyCredential) CheckIntegrity() bool
- func (kc *KeyCredential) ComputeKeyHash() []byte
- func (kc *KeyCredential) Describe(indent int)
- func (kc *KeyCredential) Marshal() ([]byte, error)
- func (kc *KeyCredential) ParseDNWithBinary(dnWithBinary ldap.DNWithBinary) error
- func (kc *KeyCredential) Unmarshal(data []byte) (int, error)
- type KeyCredentialEntryType
Constants ¶
const ( // A SHA256 hash of the Value field of the KeyMaterial entry. KeyCredentialEntryType_KeyID uint8 = 0x01 // A SHA256 hash of all entries following this entry. KeyCredentialEntryType_KeyHash uint8 = 0x02 // Key material of the credential. KeyCredentialEntryType_KeyMaterial uint8 = 0x03 // Key Usage KeyCredentialEntryType_KeyUsage uint8 = 0x04 // Key Source KeyCredentialEntryType_KeySource uint8 = 0x05 // Device Identifier KeyCredentialEntryType_DeviceId uint8 = 0x06 // Custom key information. KeyCredentialEntryType_CustomKeyInformation uint8 = 0x07 // The approximate time this key was last used, in FILETIME format. KeyCredentialEntryType_KeyApproximateLastLogonTimeStamp uint8 = 0x08 // The approximate time this key was created, in FILETIME format. KeyCredentialEntryType_KeyCreationTime uint8 = 0x09 )
Variables ¶
This section is empty.
Functions ¶
func WriteEntry ¶ added in v1.0.3
func WriteEntry(buffer *bytes.Buffer, entryType KeyCredentialEntryType, data []byte)
WriteEntry writes a typed KeyCredentialEntry to the buffer.
Parameters: - buffer: A pointer to a bytes.Buffer object. - entryType: A KeyCredentialEntryType object representing the type of the entry. - data: A byte slice representing the data to be written.
Types ¶
type KeyCredential ¶
type KeyCredential struct {
Version version.KeyCredentialVersion
Identifier string
KeyHash []byte
RawKeyMaterial crypto.RSAKeyMaterial
Usage usage.KeyUsage
LegacyUsage string
Source source.KeySource
CustomKeyInfo customkeyinformation.CustomKeyInformation
DeviceId guid.GUID
LastLogonTime utils.DateTime
CreationTime utils.DateTime
// Internal
RawBytes []byte
RawBytesSize uint32
}
KeyCredential represents a key credential structure used for authentication and authorization.
Fields: - Version: A KeyCredentialVersion object representing the version of the key credential. - Identifier: A string representing the unique identifier of the key credential. - KeyHash: A byte slice containing the hash of the key material. - RawKeyMaterial: An RSAKeyMaterial object representing the raw RSA key material. - Usage: A KeyUsage object representing the usage of the key credential. - LegacyUsage: A string representing the legacy usage of the key credential. - Source: A KeySource object representing the source of the key credential. - LastLogonTime: A DateTime object representing the last logon time associated with the key credential. - CreationTime: A DateTime object representing the creation time of the key credential. - Owner: A string representing the owner of the key credential. - RawBytes: A byte slice containing the raw binary data of the key credential. - RawBytesSize: A uint32 value representing the size of the raw binary data.
Methods: - ParseDNWithBinary: Parses the provided DNWithBinary object into the KeyCredential structure.
Note: The KeyCredential structure is used to store and manage key credentials, which are used for authentication and authorization purposes. The structure includes fields for version, identifier, key hash, raw key material, usage, legacy usage, source, last logon time, creation time, owner, and raw binary data. The ParseDNWithBinary method is used to parse a DNWithBinary object and populate the fields of the KeyCredential structure.
func NewKeyCredential ¶
func NewKeyCredential( Version version.KeyCredentialVersion, Identifier string, RawKeyMaterial crypto.RSAKeyMaterial, DeviceId guid.GUID, LastLogonTime utils.DateTime, CreationTime utils.DateTime, ) *KeyCredential
NewKeyCredential creates a new KeyCredential structure.
Parameters:
- version: A KeyCredentialVersion object representing the version of the key credential.
- Identifier: A string representing the unique identifier of the key credential.
- KeyHash: A byte slice containing the hash of the key material.
- RawKeyMaterial: An RSAKeyMaterial object representing the raw RSA key material.
- Usage: A KeyUsage object representing the usage of the key credential.
- LegacyUsage: A string representing the legacy usage of the key credential.
- Source: A KeySource object representing the source of the key credential.
- CustomKeyInfo: A CustomKeyInformation object representing the custom key information of the key credential.
- DeviceId: A GUID object representing the device ID of the key credential.
- LastLogonTime: A DateTime object representing the last logon time associated with the key credential.
- CreationTime: A DateTime object representing the creation time of the key credential.
- Owner: A string representing the owner of the key credential.
Returns:
- A pointer to a KeyCredential object.
func (*KeyCredential) CheckIntegrity ¶
func (kc *KeyCredential) CheckIntegrity() bool
CheckIntegrity checks the integrity of the key credential.
Returns: - A boolean value indicating the integrity of the key credential.
func (*KeyCredential) ComputeKeyHash ¶
func (kc *KeyCredential) ComputeKeyHash() []byte
ComputeKeyHash computes the key hash of the key credential.
Returns: - A byte slice containing the key hash.
func (*KeyCredential) Describe ¶
func (kc *KeyCredential) Describe(indent int)
Describe prints a detailed description of the KeyCredential structure.
Parameters: - indent: An integer value specifying the indentation level for the output.
func (*KeyCredential) Marshal ¶ added in v1.0.3
func (kc *KeyCredential) Marshal() ([]byte, error)
Marshal returns the raw bytes of the KeyCredential structure.
Returns: - A byte slice representing the raw bytes of the KeyCredential structure. - An error if the conversion fails.
func (*KeyCredential) ParseDNWithBinary ¶
func (kc *KeyCredential) ParseDNWithBinary(dnWithBinary ldap.DNWithBinary) error
ParseDNWithBinary parses the provided DNWithBinary object into the KeyCredential structure.
Parameters: - dnWithBinary: A DNWithBinary object containing the distinguished name and binary data to be parsed.
Returns: - An error if the parsing fails, otherwise nil.
Note: The function performs the following steps: 1. Sets the RawBytes and RawBytesSize fields to the provided binary data and its length, respectively. 2. Sets the Owner field to the distinguished name from the DNWithBinary object. 3. Parses the version information from the binary data and updates the RawBytesSize and remainder accordingly. 4. Iterates through the remaining binary data, parsing each entry based on its type and length. 5. Updates the corresponding fields of the KeyCredential structure based on the parsed entry type and data.
The function handles various entry types, including key identifier, key hash, key material, key usage, legacy usage, key source, last logon time, and creation time. Unsupported entry types, such as device ID and custom key information, are commented out for future implementation.
func (*KeyCredential) Unmarshal ¶ added in v1.0.3
func (kc *KeyCredential) Unmarshal(data []byte) (int, error)
Unmarshal parses the provided binary data into the KeyCredential structure.
Parameters: - data: A byte slice containing the binary data to be parsed.
Returns: - bytesRead: The number of bytes read from the data. - error: An error if the parsing fails, otherwise nil.
Note: The function performs the following steps: 1. Sets the RawBytes and RawBytesSize fields to the provided binary data and its length. 2. Parses the version information from the binary data. 3. Iterates through the remaining binary data, parsing each entry based on its type and length. 4. Updates the corresponding fields of the KeyCredential structure based on the parsed entry type and data.
The function handles various entry types, including: - Key identifier - Key hash - Key material - Key usage (both V2 enum and legacy string formats) - Key source - Device ID - Custom key information - Last logon timestamp - Creation time
type KeyCredentialEntryType ¶ added in v1.0.3
Key Credential Link Entry Identifier
Describes the data stored in the Value field. https://msdn.microsoft.com/en-us/library/mt220499.aspx
func (*KeyCredentialEntryType) Marshal ¶ added in v1.0.3
func (k *KeyCredentialEntryType) Marshal() ([]byte, error)
Marshal returns the raw bytes of the KeyCredentialEntryType structure.
Returns: - A byte slice representing the raw bytes of the KeyCredentialEntryType structure.
func (*KeyCredentialEntryType) String ¶ added in v1.0.3
func (k *KeyCredentialEntryType) String() string
String returns a string representation of the KeyCredentialEntryType.
Returns: - A string representing the KeyCredentialEntryType.
func (*KeyCredentialEntryType) Unmarshal ¶ added in v1.0.3
func (k *KeyCredentialEntryType) Unmarshal(data []byte) (int, error)
Unmarshal parses the provided byte slice into the KeyCredentialEntryType structure.
Parameters: - data: A byte slice containing the raw key credential entry type to be parsed.
Returns: - The number of bytes read from the data.