blob
import "github.com/TheManticoreProject/Manticore/windows/cng/bcrypt/keys/blob"
Index
- type BCRYPT_DSA_PRIVATE_BLOB
- type BCRYPT_DSA_PUBLIC_BLOB
- type BCRYPT_ECC_PRIVATE_BLOB
- type BCRYPT_ECC_PUBLIC_BLOB
- type BCRYPT_RSA_FULLPRIVATE_BLOB
- type BCRYPT_RSA_PRIVATE_BLOB
- type BCRYPT_RSA_PUBLIC_BLOB
type BCRYPT\_DSA\_PRIVATE\_BLOB
BCRYPT_DSA_PRIVATE_BLOB represents the structure used for a DSA private key BLOB in memory.
The layout of a BCRYPT_DSA_PRIVATE_BLOB in memory is as follows:
BCRYPT_DSA_KEY_BLOB
Modulus[cbKey] // Big-endian
Generator[cbKey] // Big-endian
Public[cbKey] // Big-endian
PrivateExponent[20] // Big-endian
The numbers are stored in big-endian format. See: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_dsa_key_blob
type BCRYPT_DSA_PRIVATE_BLOB struct {
// Modulus is the Modulus (P) parameter of the DSA key.
Modulus []byte // Big-endian.
// Generator is the Generator (G) parameter of the DSA key.
Generator []byte // Big-endian.
// Public is the public value (Y) of the DSA key.
Public []byte // Big-endian.
// PrivateExponent is the private value (X) of the DSA key; always 20 bytes.
PrivateExponent [20]byte // Big-endian.
}
func (*BCRYPT_DSA_PRIVATE_BLOB) Describe
func (b *BCRYPT_DSA_PRIVATE_BLOB) Describe(indent int)
Describe prints the BCRYPT_DSA_PRIVATE_BLOB structure to the console.
Parameters: - indent: The number of spaces to indent the output.
func (*BCRYPT_DSA_PRIVATE_BLOB) Equal
func (b *BCRYPT_DSA_PRIVATE_BLOB) Equal(other *BCRYPT_DSA_PRIVATE_BLOB) bool
Equal checks if two BCRYPT_DSA_PRIVATE_BLOB structures are equal.
Parameters: - other: The BCRYPT_DSA_PRIVATE_BLOB structure to compare to.
Returns: - True if the two BCRYPT_DSA_PRIVATE_BLOB structures are equal, false otherwise.
func (*BCRYPT_DSA_PRIVATE_BLOB) Marshal
func (b *BCRYPT_DSA_PRIVATE_BLOB) Marshal() ([]byte, error)
Marshal returns the raw bytes of the BCRYPT_DSA_PRIVATE_BLOB structure.
Returns: - A byte slice representing the raw bytes of the BCRYPT_DSA_PRIVATE_BLOB structure.
func (*BCRYPT_DSA_PRIVATE_BLOB) Unmarshal
func (b *BCRYPT_DSA_PRIVATE_BLOB) Unmarshal(keyHeader headers.BCRYPT_DSA_KEY_BLOB, value []byte) (int, error)
Unmarshal parses the provided byte slice into the BCRYPT_DSA_PRIVATE_BLOB structure.
Parameters: - value: A byte slice containing the raw DSA key BLOB to be parsed. - keyHeader: A struct containing the cbKey field for size.
Returns: - The number of bytes read from the byte slice. - An error if the parsing fails, otherwise nil.
type BCRYPT\_DSA\_PUBLIC\_BLOB
BCRYPT_DSA_PUBLIC_BLOB represents the structure used for a DSA public key BLOB in memory.
The layout of a BCRYPT_DSA_PUBLIC_BLOB in memory is as follows:
BCRYPT_DSA_PUBLIC_BLOB
Modulus[cbKey] // Big-endian
Generator[cbKey] // Big-endian
Public[cbKey] // Big-endian
The fields following this structure are stored in big-endian format.
See: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_dsa_key_blob
type BCRYPT_DSA_PUBLIC_BLOB struct {
// Modulus is the Modulus (P) parameter of the DSA key.
Modulus []byte // Big-endian.
// Generator is the Generator (G) parameter of the DSA key.
Generator []byte // Big-endian.
// Public is the public value (Y) of the DSA key.
Public []byte // Big-endian.
}
func (*BCRYPT_DSA_PUBLIC_BLOB) Describe
func (b *BCRYPT_DSA_PUBLIC_BLOB) Describe(indent int)
Describe prints the BCRYPT_DSA_PUBLIC_BLOB structure to the console.
Parameters: - indent: The number of spaces to indent the output.
func (*BCRYPT_DSA_PUBLIC_BLOB) Equal
func (b *BCRYPT_DSA_PUBLIC_BLOB) Equal(other *BCRYPT_DSA_PUBLIC_BLOB) bool
Equal checks if two BCRYPT_DSA_PUBLIC_BLOB structures are equal.
Parameters: - other: The BCRYPT_DSA_PUBLIC_BLOB structure to compare to.
Returns: - True if the two BCRYPT_DSA_PUBLIC_BLOB structures are equal, false otherwise.
func (*BCRYPT_DSA_PUBLIC_BLOB) Marshal
func (b *BCRYPT_DSA_PUBLIC_BLOB) Marshal() ([]byte, error)
Marshal returns the raw bytes of the BCRYPT_DSA_PUBLIC_BLOB structure.
Returns: - A byte slice representing the raw bytes of the BCRYPT_DSA_PUBLIC_BLOB structure.
func (*BCRYPT_DSA_PUBLIC_BLOB) Unmarshal
func (b *BCRYPT_DSA_PUBLIC_BLOB) Unmarshal(keyHeader headers.BCRYPT_DSA_KEY_BLOB, value []byte) (int, error)
Unmarshal parses the provided byte slice into the BCRYPT_DSA_PUBLIC_BLOB structure.
Parameters: - value: A byte slice containing the raw DSA key BLOB to be parsed. - keyHeader: A struct containing the cbKey field for size.
Returns: - The number of bytes read from the byte slice. - An error if the parsing fails, otherwise nil.
type BCRYPT\_ECC\_PRIVATE\_BLOB
BCRYPT_ECC_PRIVATE_BLOB represents the content of an ECC private key BLOB in memory.
Layout in memory (following the BCRYPT_ECC_KEY_BLOB header):
BCRYPT_ECC_KEY_BLOB
BYTE X[cbKey] // Big-endian.
BYTE Y[cbKey] // Big-endian.
BYTE d[cbKey] // Big-endian.
See: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_ecckey_blob
type BCRYPT_ECC_PRIVATE_BLOB struct {
// X is the X coordinate of the public point. Big-endian.
X []byte
// Y is the Y coordinate of the public point. Big-endian.
Y []byte
// D is the private scalar. Big-endian.
D []byte
}
func (*BCRYPT_ECC_PRIVATE_BLOB) Describe
func (b *BCRYPT_ECC_PRIVATE_BLOB) Describe(indent int)
Describe prints the BCRYPT_ECC_PRIVATE_BLOB structure to the console.
Parameters: - indent: The number of spaces to indent the output.
func (*BCRYPT_ECC_PRIVATE_BLOB) Equal
func (b *BCRYPT_ECC_PRIVATE_BLOB) Equal(other *BCRYPT_ECC_PRIVATE_BLOB) bool
Equal checks if two BCRYPT_ECC_PRIVATE_BLOB structures are equal.
Parameters: - other: The BCRYPT_ECC_PRIVATE_BLOB structure to compare to.
Returns: - True if the two BCRYPT_ECC_PRIVATE_BLOB structures are equal, false otherwise.
func (*BCRYPT_ECC_PRIVATE_BLOB) Marshal
func (b *BCRYPT_ECC_PRIVATE_BLOB) Marshal() ([]byte, error)
Marshal returns the raw bytes of the BCRYPT_ECC_PRIVATE_BLOB structure.
Returns: - A byte slice representing the raw bytes of the BCRYPT_ECC_PRIVATE_BLOB structure.
func (*BCRYPT_ECC_PRIVATE_BLOB) Unmarshal
func (b *BCRYPT_ECC_PRIVATE_BLOB) Unmarshal(keyHeader headers.BCRYPT_ECC_KEY_BLOB, value []byte) (int, error)
Unmarshal parses the provided byte slice into the BCRYPT_ECC_PRIVATE_BLOB structure.
Parameters:
- keyHeader: The already-parsed BCRYPT_ECC_KEY_BLOB header, providing cbKey.
- value: A byte slice containing the raw ECC private key BLOB content to be parsed, starting immediately after the header.
Returns: - The number of bytes read from the byte slice. - An error if the parsing fails, otherwise nil.
type BCRYPT\_ECC\_PUBLIC\_BLOB
BCRYPT_ECC_PUBLIC_BLOB represents the content of an ECC public key BLOB in memory.
Layout in memory (following the BCRYPT_ECC_KEY_BLOB header):
BCRYPT_ECC_KEY_BLOB
BYTE X[cbKey] // Big-endian.
BYTE Y[cbKey] // Big-endian.
See: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_ecckey_blob
type BCRYPT_ECC_PUBLIC_BLOB struct {
// X is the X coordinate of the public point. Big-endian.
X []byte
// Y is the Y coordinate of the public point. Big-endian.
Y []byte
}
func (*BCRYPT_ECC_PUBLIC_BLOB) Describe
func (b *BCRYPT_ECC_PUBLIC_BLOB) Describe(indent int)
Describe prints the BCRYPT_ECC_PUBLIC_BLOB structure to the console.
Parameters: - indent: The number of spaces to indent the output.
func (*BCRYPT_ECC_PUBLIC_BLOB) Equal
func (b *BCRYPT_ECC_PUBLIC_BLOB) Equal(other *BCRYPT_ECC_PUBLIC_BLOB) bool
Equal checks if two BCRYPT_ECC_PUBLIC_BLOB structures are equal.
Parameters: - other: The BCRYPT_ECC_PUBLIC_BLOB structure to compare to.
Returns: - True if the two BCRYPT_ECC_PUBLIC_BLOB structures are equal, false otherwise.
func (*BCRYPT_ECC_PUBLIC_BLOB) Marshal
func (b *BCRYPT_ECC_PUBLIC_BLOB) Marshal() ([]byte, error)
Marshal returns the raw bytes of the BCRYPT_ECC_PUBLIC_BLOB structure.
Returns: - A byte slice representing the raw bytes of the BCRYPT_ECC_PUBLIC_BLOB structure.
func (*BCRYPT_ECC_PUBLIC_BLOB) Unmarshal
func (b *BCRYPT_ECC_PUBLIC_BLOB) Unmarshal(keyHeader headers.BCRYPT_ECC_KEY_BLOB, value []byte) (int, error)
Unmarshal parses the provided byte slice into the BCRYPT_ECC_PUBLIC_BLOB structure.
Parameters:
- keyHeader: The already-parsed BCRYPT_ECC_KEY_BLOB header, providing cbKey.
- value: A byte slice containing the raw ECC public key BLOB content to be parsed, starting immediately after the header.
Returns: - The number of bytes read from the byte slice. - An error if the parsing fails, otherwise nil.
type BCRYPT\_RSA\_FULLPRIVATE\_BLOB
BCRYPT_RSA_FULLPRIVATE_BLOB represents the structure used as a header for an RSA private key BLOB in memory.
The layout of a BCRYPT_RSA_FULLPRIVATE_BLOB in memory is as follows:
BCRYPT_RSA_FULLPRIVATE_BLOB
PublicExponent[cbPublicExp] // Big-endian
Modulus[cbModulus] // Big-endian
Prime1[cbPrime1] // Big-endian
Prime2[cbPrime2] // Big-endian
Exponent1[cbExponent1] // Big-endian
Exponent2[cbExponent2] // Big-endian
Coefficient[cbCoefficient] // Big-endian
PrivateExponent[cbPrivateExp] // Big-endian
The fields following this structure (PublicExponent, Modulus, Prime1, Prime2, Exponent1, Exponent2, Coefficient, and PrivateExponent) are stored in big-endian format.
Note that in different versions of Windows, the value that PrivateExponent takes from a call of BCryptExportKey may be different as there are several mathematically equivalent representations of the PrivateExponent in cbModulus bytes. Notably, in some versions the PrivateExponent will be exported modulo (Prime1 - 1) * (Prime2 - 1), and in others it will be exported modulo LeastCommonMultiple(Prime1 - 1, Prime2 - 1).
See: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_rsaprivate_blob
type BCRYPT_RSA_FULLPRIVATE_BLOB struct {
// PublicExponent is the public exponent of the RSA key.
PublicExponent []byte // Big-endian.
// Modulus is the modulus of the RSA key.
Modulus []byte // Big-endian.
// Prime1 is the first prime of the RSA key.
Prime1 []byte // Big-endian.
// Prime2 is the second prime of the RSA key.
Prime2 []byte // Big-endian.
// Exponent1 is the first exponent of the RSA key.
Exponent1 []byte // Big-endian.
// Exponent2 is the second exponent of the RSA key.
Exponent2 []byte // Big-endian.
// Coefficient is the coefficient of the RSA key.
Coefficient []byte // Big-endian.
// PrivateExponent is the private exponent of the RSA key.
PrivateExponent []byte // Big-endian.
}
func (*BCRYPT_RSA_FULLPRIVATE_BLOB) Equal
func (b *BCRYPT_RSA_FULLPRIVATE_BLOB) Equal(other *BCRYPT_RSA_FULLPRIVATE_BLOB) bool
Equal checks if two BCRYPT_RSA_FULLPRIVATE_BLOB structures are equal.
Parameters: - other: The BCRYPT_RSA_FULLPRIVATE_BLOB structure to compare to.
Returns: - True if the two BCRYPT_RSA_FULLPRIVATE_BLOB structures are equal, false otherwise.
func (*BCRYPT_RSA_FULLPRIVATE_BLOB) Marshal
func (b *BCRYPT_RSA_FULLPRIVATE_BLOB) Marshal() ([]byte, error)
Marshal returns the raw bytes of the BCRYPT_RSA_FULLPRIVATE_BLOB structure.
Returns: - A byte slice representing the raw bytes of the BCRYPT_RSA_FULLPRIVATE_BLOB structure.
func (*BCRYPT_RSA_FULLPRIVATE_BLOB) Unmarshal
func (b *BCRYPT_RSA_FULLPRIVATE_BLOB) Unmarshal(keyHeader headers.BCRYPT_RSA_KEY_BLOB, value []byte) (int, error)
Unmarshal parses the provided byte slice into the BCRYPT_RSA_FULLPRIVATE_BLOB structure.
Parameters: - value: A byte slice containing the raw RSA full private 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 RSA full private key BLOB format, starting with the BCRYPT_RSA_KEY_BLOB header. It extracts the public exponent, modulus, prime1, prime2, exponent1, exponent2, and coefficient from the byte slice and stores them in the BCRYPT_RSA_FULLPRIVATE_BLOB structure.
type BCRYPT\_RSA\_PRIVATE\_BLOB
BCRYPT_RSA_PRIVATE_BLOB represents the structure used as a header for an RSA private key BLOB in memory.
The layout of a BCRYPT_RSA_PRIVATE_BLOB in memory is as follows:
BCRYPT_RSA_PRIVATE_BLOB
PublicExponent[cbPublicExp] // Big-endian
Modulus[cbModulus] // Big-endian
Prime1[cbPrime1] // Big-endian
Prime2[cbPrime2] // Big-endian
The fields following this structure (PublicExponent, Modulus, Prime1, and Prime2) are stored in big-endian format.
See: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_rsakey_blob
type BCRYPT_RSA_PRIVATE_BLOB struct {
// PublicExponent is the public exponent of the RSA key.
PublicExponent []byte // Big-endian.
// Modulus is the modulus of the RSA key.
Modulus []byte // Big-endian.
// Prime1 is the first prime of the RSA key.
Prime1 []byte // Big-endian.
// Prime2 is the second prime of the RSA key.
Prime2 []byte // Big-endian.
}
func (*BCRYPT_RSA_PRIVATE_BLOB) Describe
func (b *BCRYPT_RSA_PRIVATE_BLOB) Describe(indent int)
Describe prints the BCRYPT_RSA_PRIVATE_BLOB structure to the console.
Parameters: - indent: The number of spaces to indent the output.
func (*BCRYPT_RSA_PRIVATE_BLOB) Equal
func (b *BCRYPT_RSA_PRIVATE_BLOB) Equal(other *BCRYPT_RSA_PRIVATE_BLOB) bool
Equal checks if two BCRYPT_RSA_PRIVATE_BLOB structures are equal.
Parameters: - other: The BCRYPT_RSA_PRIVATE_BLOB structure to compare to.
Returns: - True if the two BCRYPT_RSA_PRIVATE_BLOB structures are equal, false otherwise.
func (*BCRYPT_RSA_PRIVATE_BLOB) Marshal
func (b *BCRYPT_RSA_PRIVATE_BLOB) Marshal() ([]byte, error)
Marshal returns the raw bytes of the BCRYPT_RSA_PRIVATE_BLOB structure.
Returns: - A byte slice representing the raw bytes of the BCRYPT_RSA_PRIVATE_BLOB structure.
func (*BCRYPT_RSA_PRIVATE_BLOB) Unmarshal
func (b *BCRYPT_RSA_PRIVATE_BLOB) Unmarshal(keyHeader headers.BCRYPT_RSA_KEY_BLOB, value []byte) (int, error)
Unmarshal parses the provided byte slice into the BCRYPT_RSA_PRIVATE_BLOB structure.
Parameters: - value: A byte slice containing the raw RSA private 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 RSA private key BLOB format, starting with the BCRYPT_RSA_KEY_BLOB header. It extracts the public exponent, modulus, prime1, and prime2 from the byte slice and stores them in the BCRYPT_RSA_PRIVATE_BLOB structure.
type BCRYPT\_RSA\_PUBLIC\_BLOB
BCRYPT_RSA_PUBLIC_BLOB represents the structure used as a header for an RSA public key BLOB in memory.
The layout of a BCRYPT_RSA_PUBLIC_BLOB in memory is as follows:
BCRYPT_RSA_PUBLIC_BLOB
PublicExponent[cbPublicExp] // Big-endian
Modulus[cbModulus] // Big-endian
The fields following this structure (PublicExponent and Modulus) are stored in big-endian format.
See: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/ns-bcrypt-bcrypt_rsakey_blob
type BCRYPT_RSA_PUBLIC_BLOB struct {
// PublicExponent is the public exponent of the RSA key.
// Stored in big-endian format.
PublicExponent []byte
// Modulus is the modulus of the RSA key.
// Stored in big-endian format.
Modulus []byte
}
func (*BCRYPT_RSA_PUBLIC_BLOB) Describe
func (b *BCRYPT_RSA_PUBLIC_BLOB) Describe(indent int)
Describe prints the BCRYPT_RSA_PUBLIC_BLOB structure to the console.
Parameters: - indent: The number of spaces to indent the output.
func (*BCRYPT_RSA_PUBLIC_BLOB) Equal
func (b *BCRYPT_RSA_PUBLIC_BLOB) Equal(other *BCRYPT_RSA_PUBLIC_BLOB) bool
Equal checks if two BCRYPT_RSA_PUBLIC_BLOB structures are equal.
Parameters: - other: The BCRYPT_RSA_PUBLIC_BLOB structure to compare to.
Returns: - True if the two BCRYPT_RSA_PUBLIC_BLOB structures are equal, false otherwise.
func (*BCRYPT_RSA_PUBLIC_BLOB) Marshal
func (b *BCRYPT_RSA_PUBLIC_BLOB) Marshal() ([]byte, error)
Marshal returns the raw bytes of the BCRYPT_RSA_PUBLIC_BLOB structure.
Returns: - A byte slice representing the raw bytes of the BCRYPT_RSA_PUBLIC_BLOB structure.
func (*BCRYPT_RSA_PUBLIC_BLOB) Unmarshal
func (b *BCRYPT_RSA_PUBLIC_BLOB) Unmarshal(keyHeader headers.BCRYPT_RSA_KEY_BLOB, value []byte) (int, error)
Unmarshal parses the provided byte slice into the BCRYPT_RSA_PUBLIC_BLOB structure.
Parameters: - value: A byte slice containing the raw RSA public 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 RSA public key BLOB format, starting with the BCRYPT_RSA_KEY_BLOB header. It extracts the public exponent and modulus from the byte slice and stores them in the BCRYPT_RSA_PUBLIC_BLOB structure.