+ *colon = '\0';
+
+ len = colon - decode;
+ if (strlen(decode) > strlen("-hmac96") &&
+ !strcmp(decode + strlen(decode) - strlen("-hmac96"),
+ "-hmac96")) {
+ p = strstr(decode, "-hmac96");
+ *p = '\0';
+ authlen = 12;
+ }
+ if (strlen(decode) > strlen("-cbc") &&
+ !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) {
+ p = strstr(decode, "-cbc");
+ *p = '\0';
+ }
+ evp = EVP_get_cipherbyname(decode);
+ if (!evp) {
+ (*ndo->ndo_warning)(ndo, "failed to find cipher algo %s\n", decode);
+ sa1.evp = NULL;
+ sa1.authlen = 0;
+ sa1.ivlen = 0;
+ return;
+ }
+
+ sa1.evp = evp;
+ sa1.authlen = authlen;
+ sa1.ivlen = EVP_CIPHER_iv_length(evp);
+
+ colon++;
+ if (colon[0] == '0' && colon[1] == 'x') {
+ /* decode some hex! */
+ colon += 2;
+ len = strlen(colon) / 2;
+
+ if (len > 256) {
+ (*ndo->ndo_warning)(ndo, "secret is too big: %d\n", len);
+ return;
+ }
+
+ i = 0;
+ while (colon[0] != '\0' && colon[1]!='\0') {
+ espsecret_key[i] = hex2byte(ndo, colon);
+ colon += 2;
+ i++;
+ }
+
+ memcpy(sa1.secret, espsecret_key, i);
+ sa1.secretlen = i;
+ } else {
+ i = strlen(colon);
+
+ if (i < sizeof(sa1.secret)) {
+ memcpy(sa1.secret, colon, i);
+ sa1.secretlen = i;
+ } else {
+ memcpy(sa1.secret, colon, sizeof(sa1.secret));
+ sa1.secretlen = sizeof(sa1.secret);
+ }
+ }
+ }
+
+ esp_print_addsa(ndo, &sa1, sa_def);
+}
+
+static void esp_print_decodesecret(netdissect_options *ndo)
+{
+ char *line;
+ char *p;
+
+ p = ndo->ndo_espsecret;
+
+ while (ndo->ndo_espsecret && ndo->ndo_espsecret[0] != '\0') {
+ /* pick out the first line or first thing until a comma */
+ if ((line = strsep(&ndo->ndo_espsecret, "\n,")) == NULL) {
+ line = ndo->ndo_espsecret;
+ ndo->ndo_espsecret = NULL;