3

Rockbox 用のパスワード格納プラグイン (C で記述) の場合、初期化ベクトルを生成する必要があります。

問題は、ランダム性の良いソースがないことです。Rockbox が提供する random() は暗号化 RNG ではありません。そして、アクセスできるランダム性のソースはほとんどありません(マウスの動きはありません... Rockboxを実行しているiPodでは)。

キーは現在、PBKDF2 を介してユーザー提供のパスワードとソルト (定数プレフィックス + random() からのデータ) から導出されます。疑似乱数データは、PBKDF2 の 10000 回の反復でソルトに十分なはずだと思います。

しかし、どこから初期化ベクトルを取得しますか? 半ランダムなデータ (time + random()) と SHA を、たとえば 10000 回取得しても問題ありませんか? random() から取得したシードで arc4random を取得する必要がありますか?

同じキーを実質的に 2 回使用しない場合 (保存されたデータが変更されるたびにソルトが再計算されます)、IV も必要ですか? このような状況に対処する最善の方法は何ですか?

編集: 1 人のユーザー (IPod を所有している私)、暗号化アルゴリズム: AES-CBC 256 ビット。このファイルには、さまざまな Web サイトのサイト/アカウント/パスワード リストが格納されているだけです。それが変更されることはめったにありません (Web サイトで新しいアカウントを作成するときはいつでも)。変更が行われると、新しいソルトと新しい IV が生成されます。

4

3 に答える 3

2

Generally speaking, with CBC, the IV MUST be random and uniform. "Non-repeating" is not sufficient. To be more precise, the whole point of CBC is to avoid the situation where the same data block is fed twice to the underlying block cipher. Hence, the condition is that if you encrypt two messages with the same key, then the difference of the two IV must be uniformly random. With a 128-bit block cipher such as the AES, the probability that the same block is obtained twice is sufficiently low as to be neglected -- as long as the IV is randomly chosen with uniform probability over the whole space of 128-bit values. Any structure in the IV selection (such as reusing the same IV, using a counter, or a low-quality random generator) increases that probability, because you are encrypting data which has itself a lot of structure.

There is a bright side to that: if you never use the same key twice, then you can tolerate a fixed IV. But that is a strong "never".

"Non-repeating IV" is not a good enough property with CBC. However, there are some encryption modes which can use non-repeating IV. In particular, have a look at EAX and GCM. The trick here is that those mode use the provided IV in a custom PRNG which uses the encryption key; this transform the non-repeating IV (e.g. a counter, or a "random value" of low quality) into something which, from a cryptographic point of view, looks random enough. Do not try to build your own PRNG ! These things are subtle and there is no sure way to test the quality of the result.

于 2011-01-17T18:24:52.533 に答える
2

IV はランダムである必要はありません。特定のキーとデータのペアに対して一意である必要があります (CBC の IV について話していると仮定します)。

したがって、この目的には random() で問題ありません。

于 2011-01-14T21:32:21.783 に答える
2

素晴らしいニュース!初期化ベクトルはランダムである必要はありません。暗号化ごとに異なる必要があるだけです。したがって、ユーザーの名前をソルトとして使用できます。ユーザー名と時刻の両方を使用すると、攻撃者はパスワードの再利用を検出できなくなります。

于 2011-01-14T21:34:03.427 に答える