headers

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BCRYPT_DSA_KEY_BLOB

type BCRYPT_DSA_KEY_BLOB struct {
	// The length, in bytes, of the key.
	CbKey uint32

	// The counter value used during the generation of the key.
	Count [4]byte

	// The seed used for key generation.
	Seed [20]byte

	// The DSA q parameter.
	Q [20]byte
}

BCRYPT_DSA_KEY_BLOB structure is used to represent the header of a DSA key BLOB in memory.

Source: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_dsa_key_blob

This structure is used as the header for buffers that store DSA public/private key material.

func (*BCRYPT_DSA_KEY_BLOB) Describe

func (b *BCRYPT_DSA_KEY_BLOB) Describe(indent int)

Describe prints the BCRYPT_DSA_KEY_BLOB structure to the console.

func (*BCRYPT_DSA_KEY_BLOB) Marshal

func (b *BCRYPT_DSA_KEY_BLOB) Marshal() ([]byte, error)

Marshal returns the raw bytes of the BCRYPT_DSA_KEY_BLOB structure.

func (*BCRYPT_DSA_KEY_BLOB) Unmarshal

func (b *BCRYPT_DSA_KEY_BLOB) Unmarshal(value []byte) (int, error)

Unmarshal parses the provided byte slice into the BCRYPT_DSA_KEY_BLOB structure.

type BCRYPT_ECC_KEY_BLOB

type BCRYPT_ECC_KEY_BLOB struct {
	// The length, in bytes, of the key.
	KeySize uint32
}

BCRYPT_ECC_KEY_BLOB structure is used as a header for an elliptic curve key BLOB in memory.

Source: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_ecckey_blob

Remarks: This structure is used as a header for a larger buffer. An elliptic curve public key BLOB (BCRYPT_ECCPUBLIC_BLOB) has the following format in contiguous memory. The X and Y coordinates are unsigned integers encoded in big-endian format.

Syntax: BCRYPT_ECC_KEY_BLOB BYTE X[cbKey] // Big-endian. BYTE Y[cbKey] // Big-endian.

An elliptic curve private key BLOB (BCRYPT_ECCPRIVATE_BLOB) has the following format in contiguous memory. The X and Y coordinates and d value are unsigned integers encoded in big-endian format.

Syntax: BCRYPT_ECC_KEY_BLOB BYTE X[cbKey] // Big-endian. BYTE Y[cbKey] // Big-endian. BYTE d[cbKey] // Big-endian.

func (*BCRYPT_ECC_KEY_BLOB) Describe

func (b *BCRYPT_ECC_KEY_BLOB) Describe(indent int)

Describe prints the BCRYPT_ECC_KEY_BLOB structure to the console.

Parameters: - indent: The number of spaces to indent the output.

func (*BCRYPT_ECC_KEY_BLOB) Marshal

func (b *BCRYPT_ECC_KEY_BLOB) Marshal() ([]byte, error)

Marshal returns the raw bytes of the BCRYPT_ECC_KEY_BLOB structure.

Returns: - A byte slice representing the raw bytes of the BCRYPT_ECC_KEY_BLOB structure.

func (*BCRYPT_ECC_KEY_BLOB) Unmarshal

func (b *BCRYPT_ECC_KEY_BLOB) Unmarshal(value []byte) (int, error)

Unmarshal parses the provided byte slice into the BCRYPT_ECC_KEY_BLOB structure.

Parameters: - value: A byte slice containing the raw elliptic curve key BLOB to be parsed.

Returns: - The number of bytes read from the byte slice. - An error if the parsing fails, otherwise nil.

Note: The function expects the byte slice to follow the elliptic curve key BLOB format, starting with the "ECC1" blob type identifier. It extracts the key size from the byte slice and stores it in the BCRYPT_ECC_KEY_BLOB structure.

type BCRYPT_RSA_KEY_BLOB

type BCRYPT_RSA_KEY_BLOB struct {
	// The size, in bits, of the key.
	BitLength uint32

	// The size, in bytes, of the exponent of the key.
	// As of Windows 10 version 1903, public exponents larger than (2^64 - 1) are no longer supported.
	CbPublicExp uint32

	// The size, in bytes, of the modulus of the key.
	CbModulus uint32

	// The size, in bytes, of the first prime number of the key. This is only used for private key BLOBs.
	CbPrime1 uint32

	// The size, in bytes, of the second prime number of the key. This is only used for private key BLOBs.
	CbPrime2 uint32
}

BCRYPT_RSA_KEY_BLOB structure is used as a header for an RSA public key or private key BLOB in memory.

See: https://docs.microsoft.com/en-us/archive/msdn-magazine/2007/july/applying-cryptography-using-the-cng-api-in-windows-vista https://docs.microsoft.com/en-us/archive/msdn-magazine/2007/july/images/cc163389.fig11.gif https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_rsakey_blob

func (*BCRYPT_RSA_KEY_BLOB) Describe

func (k *BCRYPT_RSA_KEY_BLOB) Describe(indent int)

Describe prints a detailed description of the BCRYPT_RSA_KEY_BLOB instance.

Parameters: - indent: An integer representing the indentation level for the printed output.

Note: This function prints the Exponent, Modulus, Prime1, and Prime2 values of the BCRYPT_RSA_KEY_BLOB instance. The output is formatted with the specified indentation level to improve readability. If Prime1 or Prime2 is not set, the function prints "None" for the respective value.

func (*BCRYPT_RSA_KEY_BLOB) Equal

func (k *BCRYPT_RSA_KEY_BLOB) Equal(other *BCRYPT_RSA_KEY_BLOB) bool

Equal checks if two BCRYPT_RSA_KEY_BLOB structures are equal.

Parameters: - other: The BCRYPT_RSA_KEY_BLOB structure to compare to.

Returns: - True if the two BCRYPT_RSA_KEY_BLOB structures are equal, false otherwise.

func (*BCRYPT_RSA_KEY_BLOB) Marshal

func (k *BCRYPT_RSA_KEY_BLOB) Marshal() ([]byte, error)

Marshal returns the raw bytes of the BCRYPT_RSA_KEY_BLOB structure.

Returns: - A byte slice representing the raw bytes of the BCRYPT_RSA_KEY_BLOB structure.

func (*BCRYPT_RSA_KEY_BLOB) String

func (k *BCRYPT_RSA_KEY_BLOB) String() string

String returns a string representation of the BCRYPT_RSA_KEY_BLOB structure.

Returns: - A string representing the BCRYPT_RSA_KEY_BLOB structure.

func (*BCRYPT_RSA_KEY_BLOB) Unmarshal

func (k *BCRYPT_RSA_KEY_BLOB) Unmarshal(value []byte) (int, error)

Unmarshal parses the provided byte slice into the BCRYPT_RSA_KEY_BLOB structure.

Parameters: - value: A byte slice containing the raw RSA key material to be parsed.

Returns: - The number of bytes read from the byte slice. - An error if the parsing fails, otherwise nil.

Note: The function expects the byte slice to follow the RSA key blob format, starting with the "RSA1" blob type identifier. It extracts the key size, exponent size, modulus size, prime1 size, and prime2 size from the header, and then parses the corresponding values from the body of the byte slice. The parsed values are stored in the BCRYPT_RSA_KEY_BLOB structure.

The function performs the following steps: 1. Sets the RawBytes and RawBytesSize fields to the provided byte slice and its length, respectively. 2. Checks if the blob type is "RSA1". If not, it returns an error. 3. Extracts the key size, exponent size, modulus size, prime1 size, and prime2 size from the header. 4. Parses the exponent, modulus, prime1, and prime2 values from the body of the byte slice based on the extracted sizes. 5. Stores the parsed values in the corresponding fields of the BCRYPT_RSA_KEY_BLOB structure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL