Skip to content

Commit 98e9069

Browse files
committed
Add support for draft SNMPv3 AES192 and AES 256 (and Cisco variant) security protocols (#21451)
1 parent a151551 commit 98e9069

3 files changed

Lines changed: 39 additions & 5 deletions

File tree

ext/snmp/snmp.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,13 +1060,47 @@ static ZEND_ATTRIBUTE_NONNULL bool snmp_session_set_sec_protocol(struct snmp_ses
10601060
s->securityPrivProtoLen = USM_PRIV_PROTO_AES_LEN;
10611061
return true;
10621062
}
1063+
1064+
# ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04
1065+
if (zend_string_equals_literal_ci(prot, "AES192")) {
1066+
s->securityPrivProto = usmAES192PrivProtocol;
1067+
s->securityPrivProtoLen = OID_LENGTH(usmAES192PrivProtocol);
1068+
return true;
1069+
}
1070+
1071+
if (zend_string_equals_literal_ci(prot, "AES256")) {
1072+
s->securityPrivProto = usmAES256PrivProtocol;
1073+
s->securityPrivProtoLen = OID_LENGTH(usmAES256PrivProtocol);
1074+
return true;
1075+
}
1076+
1077+
if (zend_string_equals_literal_ci(prot, "AES192C")) {
1078+
s->securityPrivProto = usmAES192CiscoPrivProtocol;
1079+
s->securityPrivProtoLen = OID_LENGTH(usmAES192CiscoPrivProtocol);
1080+
return true;
1081+
}
1082+
1083+
if (zend_string_equals_literal_ci(prot, "AES256C")) {
1084+
s->securityPrivProto = usmAES256CiscoPrivProtocol;
1085+
s->securityPrivProtoLen = OID_LENGTH(usmAES256CiscoPrivProtocol);
1086+
return true;
1087+
}
1088+
# endif
10631089
#endif
10641090

10651091
#ifdef HAVE_AES
1066-
# ifndef NETSNMP_DISABLE_DES
1067-
zend_value_error("Security protocol must be one of \"DES\", \"AES128\", or \"AES\"");
1092+
# ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04
1093+
# ifndef NETSNMP_DISABLE_DES
1094+
zend_value_error("Security protocol must be one of \"AES256\", \"AES256C\", \"AES192\", \"AES192C\", \"AES128\", \"AES\", or \"DES\"");
1095+
# else
1096+
zend_value_error("Security protocol must be one of \"AES256\", \"AES256C\", \"AES192\", \"AES192C\", \"AES128\", or \"AES\"");
1097+
# endif
10681098
# else
1099+
# ifndef NETSNMP_DISABLE_DES
1100+
zend_value_error("Security protocol must be one of \"AES128\", \"AES\", or \"DES\"");
1101+
# else
10691102
zend_value_error("Security protocol must be one of \"AES128\", or \"AES\"");
1103+
# endif
10701104
# endif
10711105
#else
10721106
# ifndef NETSNMP_DISABLE_DES

ext/snmp/tests/snmp-object-setSecurity_error.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ bool(false)
7272

7373
Warning: SNMP::setSecurity(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d
7474
bool(false)
75-
Security protocol must be one of "DES", "AES128", or "AES"
76-
Security protocol must be one of "DES", "AES128", or "AES"
75+
Security protocol must be one of %s
76+
Security protocol must be one of %s
7777

7878
Warning: SNMP::setSecurity(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
7979
bool(false)

ext/snmp/tests/snmp3-error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bool(false)
6868

6969
Warning: snmp3_get(): Error generating a key for authentication pass phrase 'te': Generic error (The supplied password length is too short.) in %s on line %d
7070
bool(false)
71-
Security protocol must be one of "DES", "AES128", or "AES"
71+
Security protocol must be one of %s
7272

7373
Warning: snmp3_get(): Error generating a key for privacy pass phrase '': Generic error (The supplied password length is too short.) in %s on line %d
7474
bool(false)

0 commit comments

Comments
 (0)