sipeed/picoclaw · error

ciphertext length %d is not a multiple of block size

Error message

ciphertext length %d is not a multiple of block size

What it means

Error "ciphertext length %d is not a multiple of block size" thrown in sipeed/picoclaw.

Source

Thrown at pkg/channels/wecom/media.go:109

	if err == nil && len(key) == 32 {
		return key, nil
	}
	key, err = base64.StdEncoding.DecodeString(value + "=")
	if err != nil {
		return nil, fmt.Errorf("decode AES key: %w", err)
	}
	if len(key) != 32 {
		return nil, fmt.Errorf("invalid AES key length %d", len(key))
	}
	return key, nil
}

func decryptAESCBC(key, ciphertext []byte) ([]byte, error) {
	if len(ciphertext) == 0 {
		return nil, fmt.Errorf("ciphertext is empty")
	}
	if len(ciphertext)%aes.BlockSize != 0 {
		return nil, fmt.Errorf("ciphertext length %d is not a multiple of block size", len(ciphertext))
	}
	block, err := aes.NewCipher(key)
	if err != nil {
		return nil, fmt.Errorf("create cipher: %w", err)
	}
	plaintext := make([]byte, len(ciphertext))
	iv := key[:aes.BlockSize]
	cipher.NewCBCDecrypter(block, iv).CryptBlocks(plaintext, ciphertext)
	return pkcs7Unpad(plaintext)
}

func pkcs7Unpad(data []byte) ([]byte, error) {
	if len(data) == 0 {
		return nil, fmt.Errorf("empty plaintext")
	}
	padding := int(data[len(data)-1])
	if padding == 0 || padding > 32 || padding > len(data) {
		return nil, fmt.Errorf("invalid padding size %d", padding)

View on GitHub (pinned to 49183d7e8d)

When it happens

Trigger: Thrown at pkg/channels/wecom/media.go:109 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/65e89f1043949f61. Report an issue: GitHub.