| 103 | } |
| 104 | |
| 105 | void Key_file::Entry::load_legacy (uint32_t arg_version, std::istream& in) |
| 106 | { |
| 107 | version = arg_version; |
| 108 | |
| 109 | // First comes the AES key |
| 110 | in.read(reinterpret_cast<char*>(aes_key), AES_KEY_LEN); |
| 111 | if (in.gcount() != AES_KEY_LEN) { |
| 112 | throw Malformed(); |
| 113 | } |
| 114 | |
| 115 | // Then the HMAC key |
| 116 | in.read(reinterpret_cast<char*>(hmac_key), HMAC_KEY_LEN); |
| 117 | if (in.gcount() != HMAC_KEY_LEN) { |
| 118 | throw Malformed(); |
| 119 | } |
| 120 | |
| 121 | if (in.peek() != -1) { |
| 122 | // Trailing data is a good indication that we are not actually reading a |
| 123 | // legacy key file. (This is important to check since legacy key files |
| 124 | // did not have any sort of file header.) |
| 125 | throw Malformed(); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | void Key_file::Entry::store (std::ostream& out) const |
| 130 | { |
no test coverage detected