|
|
a51664 |
diff -urNp old/doc/ipmitool.1 new/doc/ipmitool.1
|
|
|
a51664 |
--- old/doc/ipmitool.1 2017-02-06 10:20:02.254362909 +0100
|
|
|
a51664 |
+++ new/doc/ipmitool.1 2017-02-06 10:33:41.729294474 +0100
|
|
|
a51664 |
@@ -372,6 +372,20 @@ Configure user access information on the
|
|
|
a51664 |
|
|
|
a51664 |
Displays the list of cipher suites supported for the given
|
|
|
a51664 |
application (ipmi or sol) on the given channel.
|
|
|
a51664 |
+.TP
|
|
|
a51664 |
+\fIsetkg\fP <\fIhex\fP|\fIplain\fP> <\fBkey\fP> [<\fBchannel\fR>]
|
|
|
a51664 |
+.br
|
|
|
a51664 |
+
|
|
|
a51664 |
+Sets K_g key to given value. Use \fIplain\fP to specify \fBkey\fR as simple ASCII string.
|
|
|
a51664 |
+Use \fIhex\fP to specify \fBkey\fR as sequence of hexadecimal codes of ASCII charactes.
|
|
|
a51664 |
+I.e. following two examples are equivalent:
|
|
|
a51664 |
+
|
|
|
a51664 |
+.RS
|
|
|
a51664 |
+ipmitool channel setkg plain PASSWORD
|
|
|
a51664 |
+
|
|
|
a51664 |
+ipmitool channel setkg hex 50415353574F5244
|
|
|
a51664 |
+.RE
|
|
|
a51664 |
+
|
|
|
a51664 |
.RE
|
|
|
a51664 |
.RE
|
|
|
a51664 |
.TP
|
|
|
a51664 |
diff -urNp old/include/ipmitool/helper.h new/include/ipmitool/helper.h
|
|
|
a51664 |
--- old/include/ipmitool/helper.h 2017-02-06 10:20:02.254362909 +0100
|
|
|
a51664 |
+++ new/include/ipmitool/helper.h 2017-02-06 10:40:07.336136844 +0100
|
|
|
a51664 |
@@ -58,6 +58,8 @@
|
|
|
a51664 |
# define IPMI_UID_MAX 63
|
|
|
a51664 |
#endif
|
|
|
a51664 |
|
|
|
a51664 |
+#define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */
|
|
|
a51664 |
+
|
|
|
a51664 |
struct ipmi_intf;
|
|
|
a51664 |
|
|
|
a51664 |
struct valstr {
|
|
|
a51664 |
diff -urNp old/include/ipmitool/ipmi_channel.h new/include/ipmitool/ipmi_channel.h
|
|
|
a51664 |
--- old/include/ipmitool/ipmi_channel.h 2017-02-06 10:20:02.253316684 +0100
|
|
|
a51664 |
+++ new/include/ipmitool/ipmi_channel.h 2017-02-06 10:58:15.291287621 +0100
|
|
|
a51664 |
@@ -49,6 +49,10 @@
|
|
|
a51664 |
#define IPMI_GET_USER_NAME 0x46
|
|
|
a51664 |
#define IPMI_SET_USER_PASSWORD 0x47
|
|
|
a51664 |
#define IPMI_GET_CHANNEL_CIPHER_SUITES 0x54
|
|
|
a51664 |
+#define IPMI_SET_CHANNEL_SECURITY_KEYS 0x56
|
|
|
a51664 |
+
|
|
|
a51664 |
+#define IPMI_KG_KEY_ID 1
|
|
|
a51664 |
+#define IPMI_SET_CHANNEL_SECURITY_KEYS_OP_SET 1
|
|
|
a51664 |
|
|
|
a51664 |
/* These are for channel_info_t.session_support */
|
|
|
a51664 |
#define IPMI_CHANNEL_SESSION_LESS 0x00
|
|
|
a51664 |
@@ -137,6 +141,40 @@ int _ipmi_set_channel_access(struct ipmi
|
|
|
a51664 |
struct channel_access_t channel_access, uint8_t access_option,
|
|
|
a51664 |
uint8_t privilege_option);
|
|
|
a51664 |
|
|
|
a51664 |
+struct set_channel_security_keys_req {
|
|
|
a51664 |
+#if WORDS_BIGENDIAN
|
|
|
a51664 |
+ uint8_t __reserved1 :4;
|
|
|
a51664 |
+ uint8_t channel :4;
|
|
|
a51664 |
+
|
|
|
a51664 |
+ uint8_t __reserved2 :6;
|
|
|
a51664 |
+ uint8_t operation :2;
|
|
|
a51664 |
+
|
|
|
a51664 |
+ uint8_t key_id;
|
|
|
a51664 |
+ unsigned char key_value[IPMI_KG_BUFFER_SIZE-1]; /* we don't want space for '\0' at the end */
|
|
|
a51664 |
+#else
|
|
|
a51664 |
+ uint8_t channel :4;
|
|
|
a51664 |
+ uint8_t __reserved1 :4;
|
|
|
a51664 |
+
|
|
|
a51664 |
+ uint8_t operation :2;
|
|
|
a51664 |
+ uint8_t __reserved2 :6;
|
|
|
a51664 |
+
|
|
|
a51664 |
+ uint8_t key_id;
|
|
|
a51664 |
+ unsigned char key_value[IPMI_KG_BUFFER_SIZE-1]; /* we don't want space for '\0' at the end */
|
|
|
a51664 |
+#endif
|
|
|
a51664 |
+} __attribute__ ((packed));
|
|
|
a51664 |
+
|
|
|
a51664 |
+struct set_channel_security_keys_rsp {
|
|
|
a51664 |
+#if WORDS_BIGENDIAN
|
|
|
a51664 |
+ uint8_t __reserved1 :6;
|
|
|
a51664 |
+ uint8_t lock_status :2;
|
|
|
a51664 |
+ unsigned char key_value; /* just the first character, use &key_value to explore the rest */
|
|
|
a51664 |
+#else
|
|
|
a51664 |
+ uint8_t lock_status :2;
|
|
|
a51664 |
+ uint8_t __reserved1 :6;
|
|
|
a51664 |
+ unsigned char key_value; /* just the first character, use &key_value to explore the rest */
|
|
|
a51664 |
+#endif
|
|
|
a51664 |
+} __attribute__ ((packed));
|
|
|
a51664 |
+
|
|
|
a51664 |
uint8_t ipmi_get_channel_medium(struct ipmi_intf * intf, uint8_t channel);
|
|
|
a51664 |
uint8_t ipmi_current_channel_medium(struct ipmi_intf * intf);
|
|
|
a51664 |
int ipmi_channel_main(struct ipmi_intf * intf, int argc, char ** argv);
|
|
|
a51664 |
diff -urNp old/include/ipmitool/ipmi_intf.h new/include/ipmitool/ipmi_intf.h
|
|
|
a51664 |
--- old/include/ipmitool/ipmi_intf.h 2017-02-06 10:20:02.254362909 +0100
|
|
|
a51664 |
+++ new/include/ipmitool/ipmi_intf.h 2017-02-06 10:40:40.264577602 +0100
|
|
|
a51664 |
@@ -60,7 +60,6 @@ enum LANPLUS_SESSION_STATE {
|
|
|
a51664 |
|
|
|
a51664 |
#define IPMI_AUTHCODE_BUFFER_SIZE 20
|
|
|
a51664 |
#define IPMI_SIK_BUFFER_SIZE IPMI_MAX_MD_SIZE
|
|
|
a51664 |
-#define IPMI_KG_BUFFER_SIZE 21 /* key plus null byte */
|
|
|
a51664 |
|
|
|
a51664 |
struct ipmi_session_params {
|
|
|
a51664 |
char * hostname;
|
|
|
a51664 |
diff -urNp old/lib/ipmi_channel.c new/lib/ipmi_channel.c
|
|
|
a51664 |
--- old/lib/ipmi_channel.c 2017-02-06 10:20:02.255409134 +0100
|
|
|
a51664 |
+++ new/lib/ipmi_channel.c 2017-02-06 12:32:14.222282317 +0100
|
|
|
a51664 |
@@ -821,6 +821,92 @@ ipmi_set_user_access(struct ipmi_intf *i
|
|
|
a51664 |
return 0;
|
|
|
a51664 |
}
|
|
|
a51664 |
|
|
|
a51664 |
+int
|
|
|
a51664 |
+ipmi_set_channel_security_keys (struct ipmi_intf *intf, uint8_t channel, const char *method, const char *key)
|
|
|
a51664 |
+{
|
|
|
a51664 |
+ uint8_t kgkey[IPMI_KG_BUFFER_SIZE];
|
|
|
a51664 |
+ struct ipmi_rs *rsp;
|
|
|
a51664 |
+ struct ipmi_rq req;
|
|
|
a51664 |
+ struct set_channel_security_keys_req req_data;
|
|
|
a51664 |
+ int rc = -1;
|
|
|
a51664 |
+
|
|
|
a51664 |
+ /* convert provided key to array of bytes */
|
|
|
a51664 |
+ if (strcmp(method, "hex") == 0) {
|
|
|
a51664 |
+ if (strlen(key) > (IPMI_KG_BUFFER_SIZE-1)*2) {
|
|
|
a51664 |
+ lprintf(LOG_ERR, "Provided key is too long, max. length is %d bytes", (IPMI_KG_BUFFER_SIZE-1));
|
|
|
a51664 |
+ printf_channel_usage();
|
|
|
a51664 |
+ return -1;
|
|
|
a51664 |
+ }
|
|
|
a51664 |
+
|
|
|
a51664 |
+ rc = ipmi_parse_hex(key, kgkey, sizeof(kgkey)-1);
|
|
|
a51664 |
+ if (rc == -1) {
|
|
|
a51664 |
+ lprintf(LOG_ERR, "Number of Kg key characters is not even");
|
|
|
a51664 |
+ return rc;
|
|
|
a51664 |
+ } else if (rc == -3) {
|
|
|
a51664 |
+ lprintf(LOG_ERR, "Kg key is not hexadecimal number");
|
|
|
a51664 |
+ return rc;
|
|
|
a51664 |
+ } else if (rc > (IPMI_KG_BUFFER_SIZE-1)) {
|
|
|
a51664 |
+ lprintf(LOG_ERR, "Kg key is too long");
|
|
|
a51664 |
+ return rc;
|
|
|
a51664 |
+ }
|
|
|
a51664 |
+
|
|
|
a51664 |
+ } else if (strcmp(method, "plain") == 0) {
|
|
|
a51664 |
+ if (strlen(key) > IPMI_KG_BUFFER_SIZE-1) {
|
|
|
a51664 |
+ lprintf(LOG_ERR, "Provided key is too long, max. length is %d bytes", (IPMI_KG_BUFFER_SIZE -1));
|
|
|
a51664 |
+ printf_channel_usage();
|
|
|
a51664 |
+ return rc;
|
|
|
a51664 |
+ }
|
|
|
a51664 |
+
|
|
|
a51664 |
+ strncpy(kgkey, key, IPMI_KG_BUFFER_SIZE-1);
|
|
|
a51664 |
+ } else {
|
|
|
a51664 |
+ printf_channel_usage();
|
|
|
a51664 |
+ return rc;
|
|
|
a51664 |
+ }
|
|
|
a51664 |
+
|
|
|
a51664 |
+ /* assemble and send request to set kg key */
|
|
|
a51664 |
+ memset(&req_data, 0, sizeof(req_data));
|
|
|
a51664 |
+ req_data.channel = channel;
|
|
|
a51664 |
+ req_data.operation = IPMI_SET_CHANNEL_SECURITY_KEYS_OP_SET;
|
|
|
a51664 |
+ req_data.key_id = IPMI_KG_KEY_ID;
|
|
|
a51664 |
+ memcpy(req_data.key_value, kgkey, IPMI_KG_BUFFER_SIZE-1);
|
|
|
a51664 |
+
|
|
|
a51664 |
+ memset(&req, 0, sizeof(req));
|
|
|
a51664 |
+ req.msg.netfn = IPMI_NETFN_APP;
|
|
|
a51664 |
+ req.msg.cmd = IPMI_SET_CHANNEL_SECURITY_KEYS;
|
|
|
a51664 |
+ req.msg.data = (uint8_t*) &req_data;
|
|
|
a51664 |
+ req.msg.data_len = sizeof(req_data);
|
|
|
a51664 |
+
|
|
|
a51664 |
+ rsp = intf->sendrecv(intf, &req;;
|
|
|
a51664 |
+ if (rsp == NULL) {
|
|
|
a51664 |
+ lprintf(LOG_ERR, "Set Channel Security Keys command failed");
|
|
|
a51664 |
+ return rc;
|
|
|
a51664 |
+ }
|
|
|
a51664 |
+ if (rsp->ccode > 0) {
|
|
|
a51664 |
+ const char *error = NULL;
|
|
|
a51664 |
+ switch (rsp->ccode) {
|
|
|
a51664 |
+ case 0x80:
|
|
|
a51664 |
+ error = "Key is locked";
|
|
|
a51664 |
+ break;
|
|
|
a51664 |
+ case 0x81:
|
|
|
a51664 |
+ error = "Insufficient key bytes";
|
|
|
a51664 |
+ break;
|
|
|
a51664 |
+ case 0x82:
|
|
|
a51664 |
+ error = "Too many key bytes";
|
|
|
a51664 |
+ break;
|
|
|
a51664 |
+ case 0x83:
|
|
|
a51664 |
+ error = "Key value does not meet criteria for K_g key";
|
|
|
a51664 |
+ break;
|
|
|
a51664 |
+ default:
|
|
|
a51664 |
+ error = val2str(rsp->ccode, completion_code_vals);
|
|
|
a51664 |
+ }
|
|
|
a51664 |
+ lprintf(LOG_ERR, "Error setting security key: %X (%s)", rsp->ccode, error);
|
|
|
a51664 |
+ return rc;
|
|
|
a51664 |
+ }
|
|
|
a51664 |
+
|
|
|
a51664 |
+ lprintf(LOG_NOTICE, "Set Channel Security Keys command succeeded");
|
|
|
a51664 |
+ return 0;
|
|
|
a51664 |
+}
|
|
|
a51664 |
+
|
|
|
a51664 |
int
|
|
|
a51664 |
ipmi_channel_main(struct ipmi_intf *intf, int argc, char **argv)
|
|
|
a51664 |
{
|
|
|
a51664 |
@@ -890,6 +976,19 @@ ipmi_channel_main(struct ipmi_intf *intf
|
|
|
a51664 |
retval = ipmi_get_channel_cipher_suites(intf,
|
|
|
a51664 |
argv[1], /* ipmi | sol */
|
|
|
a51664 |
channel);
|
|
|
a51664 |
+ } else if (strncmp(argv[0], "setkg", 5) == 0) {
|
|
|
a51664 |
+ if (argc < 3 || argc > 4)
|
|
|
a51664 |
+ printf_channel_usage();
|
|
|
a51664 |
+ else {
|
|
|
a51664 |
+ uint8_t ch = 0xe;
|
|
|
a51664 |
+ char *method = argv[1];
|
|
|
a51664 |
+ char *key = argv[2];
|
|
|
a51664 |
+ if (argc == 4) {
|
|
|
a51664 |
+ ch = (uint8_t)strtol(argv[3], NULL, 0);
|
|
|
a51664 |
+ }
|
|
|
a51664 |
+
|
|
|
a51664 |
+ retval = ipmi_set_channel_security_keys(intf, ch, method, key);
|
|
|
a51664 |
+ }
|
|
|
a51664 |
} else {
|
|
|
a51664 |
lprintf(LOG_ERR, "Invalid CHANNEL command: %s\n", argv[0]);
|
|
|
a51664 |
printf_channel_usage();
|
|
|
a51664 |
@@ -916,6 +1015,10 @@ printf_channel_usage()
|
|
|
a51664 |
lprintf(LOG_NOTICE,
|
|
|
a51664 |
"");
|
|
|
a51664 |
lprintf(LOG_NOTICE,
|
|
|
a51664 |
+" setkg hex|plain <key> [channel]");
|
|
|
a51664 |
+ lprintf(LOG_NOTICE,
|
|
|
a51664 |
+"");
|
|
|
a51664 |
+ lprintf(LOG_NOTICE,
|
|
|
a51664 |
"Possible privilege levels are:");
|
|
|
a51664 |
lprintf(LOG_NOTICE,
|
|
|
a51664 |
" 1 Callback level");
|
|
|
a51664 |
diff -urNp old/src/plugins/ipmi_intf.c new/src/plugins/ipmi_intf.c
|
|
|
a51664 |
--- old/src/plugins/ipmi_intf.c 2017-02-06 10:20:02.257501584 +0100
|
|
|
a51664 |
+++ new/src/plugins/ipmi_intf.c 2017-02-06 10:42:12.585257810 +0100
|
|
|
a51664 |
@@ -55,6 +55,7 @@
|
|
|
a51664 |
#include <ipmitool/ipmi.h>
|
|
|
a51664 |
#include <ipmitool/ipmi_sdr.h>
|
|
|
a51664 |
#include <ipmitool/log.h>
|
|
|
a51664 |
+#include <ipmitool/helper.h>
|
|
|
a51664 |
|
|
|
a51664 |
#define IPMI_DEFAULT_PAYLOAD_SIZE 25
|
|
|
a51664 |
|