-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fixed #2263, geth keys with ciphertext shorter than 32 bytes #2318
Conversation
use rustc_serialize::hex::{ToHex, FromHex, FromHexError}; | ||
|
||
#[derive(Debug, PartialEq)] | ||
pub struct Bytes(Vec<u8>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the third definition of this type afaict (rpc
, json
, and now here) -- is it possible to be more DRY?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They share the same name, but they are not the same. json::Bytes
deserialization is extremely lenient, rpc::Bytes
deserialization allows 0x
prefixes. Here, the format is very strict
@@ -92,6 +90,12 @@ macro_rules! impl_hash { | |||
} | |||
} | |||
|
|||
impl From<&'static str> for $name { | |||
fn from(s: &'static str) -> Self { | |||
s.parse().unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.expect("invalid string literal for {}: '{}'", stringify!($name), s)
would be a little more helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
CI failing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd +1 @rphmeier 's call for DRY but looks good otherwise.
CI failure is unrelated, I restarted it |
would be nice to have a test; should be merged for 1.3.2 regardless, but hopefully @NikVolf can get a test in before. |
according to Gustav, test case can be obtained by generating enough keys in geth
|
I tried that script, but keys are not printed to the output by default. I asked Gustav for help with that. I will update the pr as soon as he responds :) |
Added two test vectors for keys with length 31 and 30: https://github.com/ethereum/go-ethereum/pull/3032/files @NikVolf @debris Yes that test will generate shorter keys if enough iterations a run; how to log them: - return json.Marshal(encryptedKeyJSONV3)
+ j, err := json.Marshal(encryptedKeyJSONV3)
+ if len(keyBytes) == 31 {
+ fmt.Printf("31 keyBytes: %x\njson: %s\n", keyBytes, j)
+ }
+ return j, err |
tests are failing, I'm working on fix now :) |
* master: Fixing Delegate Call in JIT (#2378) Prioritizing re-imported transactions (#2372) Revert #2172, pretty much. (#2387) correct sync memory usage calculation (#2385) Update gitlab-ci Fix the traceAddress field in transaction traces. (#2373) Removing extras data from retracted blocks. (#2375) fixed #2263, geth keys with ciphertext shorter than 32 bytes (#2318) Expanse compatibility (#2369) Specify column cache sizes explicitly; default fallback of 2MB (#2358) Canonical state cache (master) (#2311) make block queue into a more generic verification queue and fix block heap size calculation (#2095) Hash Content RPC method (#2355) Reorder transaction_by_hash to favour canon search (#2332) DIV optimization (#2327) Error when deserializing invalid hex (#2339) Changed http:// to https:// on some links (#2349) add a test fix migration system, better errors # Conflicts: # .gitlab-ci.yml
Fixes https://github.com/ethcore/parity/issues/2263
We also need to add additional tests. @NikVolf can you send me keyfile with short ciphertext?