Skip to content

Commit

Permalink
feat: Add a preset proton profile and replace default
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Jan 18, 2024
1 parent 453addb commit ba8d53f
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions profile/preset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
}

0 comments on commit ba8d53f

Please sign in to comment.