From 520366b81cd418b5c3cf2a397800a6cd27711a4a Mon Sep 17 00:00:00 2001 From: Lukas Burkhalter Date: Tue, 12 Dec 2023 11:13:09 +0100 Subject: [PATCH] feat: Add a preset proton profile and replace default --- profile/preset.go | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/profile/preset.go b/profile/preset.go index f54eac7d..46fba69e 100644 --- a/profile/preset.go +++ b/profile/preset.go @@ -29,25 +29,7 @@ func PresetProfiles() []string { // Default returns a custom profile that support features // that are widely implemented. func Default() *Custom { - setKeyAlgorithm := func(cfg *packet.Config, securityLevel int8) { - cfg.Algorithm = packet.PubKeyAlgoEdDSA - switch securityLevel { - case constants.HighSecurity: - cfg.Curve = packet.Curve25519 - default: - cfg.Curve = packet.Curve25519 - } - } - return &Custom{ - Name: "default", - SetKeyAlgorithm: setKeyAlgorithm, - Hash: crypto.SHA256, - CipherEncryption: packet.CipherAES256, - CompressionAlgorithm: packet.CompressionZLIB, - CompressionConfiguration: &packet.CompressionConfig{ - Level: 6, - }, - } + return ProtonV1() } // RFC4880 returns a custom profile for this library @@ -125,3 +107,29 @@ func CryptoRefresh() *Custom { V6: true, } } + +// ProtonV1 is the version 1 profile used in proton clients. +func ProtonV1() *Custom { + setKeyAlgorithm := func(cfg *packet.Config, securityLevel int8) { + cfg.Algorithm = packet.PubKeyAlgoEdDSA + switch securityLevel { + case constants.HighSecurity: + cfg.Curve = packet.Curve25519 + default: + cfg.Curve = packet.Curve25519 + } + } + return &Custom{ + Name: "proton-v1", + SetKeyAlgorithm: setKeyAlgorithm, + Hash: crypto.SHA256, + CipherEncryption: packet.CipherAES256, + CompressionAlgorithm: packet.CompressionZLIB, + CompressionConfiguration: &packet.CompressionConfig{ + Level: 6, + }, + DisableIntendedRecipients: true, + AllowAllPublicKeyAlgorithms: true, + AllowWeakRSA: true, + } +}