| 4734 | #endif |
| 4735 | |
| 4736 | static void |
| 4737 | printkey(const struct ieee80211req_key *ik) |
| 4738 | { |
| 4739 | static const uint8_t zerodata[IEEE80211_KEYBUF_SIZE]; |
| 4740 | u_int keylen = ik->ik_keylen; |
| 4741 | int printcontents; |
| 4742 | |
| 4743 | printcontents = printkeys && |
| 4744 | (memcmp(ik->ik_keydata, zerodata, keylen) != 0 || verbose); |
| 4745 | if (printcontents) |
| 4746 | LINE_BREAK(); |
| 4747 | switch (ik->ik_type) { |
| 4748 | case IEEE80211_CIPHER_WEP: |
| 4749 | /* compatibility */ |
| 4750 | LINE_CHECK("wepkey %u:%s", ik->ik_keyix+1, |
| 4751 | keylen <= 5 ? "40-bit" : |
| 4752 | keylen <= 13 ? "104-bit" : "128-bit"); |
| 4753 | break; |
| 4754 | case IEEE80211_CIPHER_TKIP: |
| 4755 | if (keylen > 128/8) |
| 4756 | keylen -= 128/8; /* ignore MIC for now */ |
| 4757 | LINE_CHECK("TKIP %u:%u-bit", ik->ik_keyix+1, 8*keylen); |
| 4758 | break; |
| 4759 | case IEEE80211_CIPHER_AES_OCB: |
| 4760 | LINE_CHECK("AES-OCB %u:%u-bit", ik->ik_keyix+1, 8*keylen); |
| 4761 | break; |
| 4762 | case IEEE80211_CIPHER_AES_CCM: |
| 4763 | LINE_CHECK("AES-CCM %u:%u-bit", ik->ik_keyix+1, 8*keylen); |
| 4764 | break; |
| 4765 | case IEEE80211_CIPHER_CKIP: |
| 4766 | LINE_CHECK("CKIP %u:%u-bit", ik->ik_keyix+1, 8*keylen); |
| 4767 | break; |
| 4768 | case IEEE80211_CIPHER_NONE: |
| 4769 | LINE_CHECK("NULL %u:%u-bit", ik->ik_keyix+1, 8*keylen); |
| 4770 | break; |
| 4771 | default: |
| 4772 | LINE_CHECK("UNKNOWN (0x%x) %u:%u-bit", |
| 4773 | ik->ik_type, ik->ik_keyix+1, 8*keylen); |
| 4774 | break; |
| 4775 | } |
| 4776 | if (printcontents) { |
| 4777 | u_int i; |
| 4778 | |
| 4779 | printf(" <"); |
| 4780 | for (i = 0; i < keylen; i++) |
| 4781 | printf("%02x", ik->ik_keydata[i]); |
| 4782 | printf(">"); |
| 4783 | if (ik->ik_type != IEEE80211_CIPHER_WEP && |
| 4784 | (ik->ik_keyrsc != 0 || verbose)) |
| 4785 | printf(" rsc %ju", (uintmax_t)ik->ik_keyrsc); |
| 4786 | if (ik->ik_type != IEEE80211_CIPHER_WEP && |
| 4787 | (ik->ik_keytsc != 0 || verbose)) |
| 4788 | printf(" tsc %ju", (uintmax_t)ik->ik_keytsc); |
| 4789 | if (ik->ik_flags != 0 && verbose) { |
| 4790 | const char *sep = " "; |
| 4791 | |
| 4792 | if (ik->ik_flags & IEEE80211_KEY_XMIT) |
| 4793 | printf("%stx", sep), sep = "+"; |
no test coverage detected