Documentation
¶
Overview ¶
Package crypto provides cryptographic functions for .doc file decryption.
This package implements the RC4 encryption/decryption algorithm used by Microsoft Word documents for password protection and encryption.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateDecryptionKey ¶
GenerateDecryptionKey creates the decryption key from password and document salt. This follows the MS-DOC specification for password-based encryption.
func GeneratePasswordHash ¶
GeneratePasswordHash creates a password hash compatible with Word documents. This implements the Word 97-2003 password hashing algorithm.
Types ¶
type EncryptionHeader ¶
type EncryptionHeader struct {
Version uint16 // Encryption version
EncryptionFlags uint32 // Encryption flags
HeaderSize uint32 // Size of encryption header
ProviderType uint32 // Cryptographic provider type
AlgID uint32 // Algorithm identifier
AlgHashID uint32 // Hash algorithm identifier
KeySize uint32 // Key size in bits
ProviderName string // Cryptographic provider name
Salt []byte // Random salt for key derivation
EncryptedVerifier []byte // Encrypted verifier for password validation
VerifierHash []byte // Hash of the verifier
}
EncryptionHeader represents the encryption information stored in the table stream for encrypted Word documents.
func ParseEncryptionHeader ¶
func ParseEncryptionHeader(data []byte) (*EncryptionHeader, error)
ParseEncryptionHeader parses the encryption header from table stream data.
func (*EncryptionHeader) CreateDecryptionCipher ¶
func (h *EncryptionHeader) CreateDecryptionCipher(password string) (*RC4, error)
CreateDecryptionCipher creates an RC4 cipher for decrypting document content.
func (*EncryptionHeader) IsPasswordProtected ¶
func (h *EncryptionHeader) IsPasswordProtected() bool
IsPasswordProtected returns true if the document is password protected.
func (*EncryptionHeader) IsRC4Encryption ¶
func (h *EncryptionHeader) IsRC4Encryption() bool
IsRC4Encryption returns true if the encryption uses RC4 algorithm.
func (*EncryptionHeader) ValidatePassword ¶
func (h *EncryptionHeader) ValidatePassword(password string) (bool, error)
ValidatePassword checks if the provided password is correct for this document.