0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

#0006 SHASUMとは

Posted at

はじめに

  • dockerのファイルシステムのアップデートを最近考えている。
  • いかに軽量でアップデートできるかが課題である。
  • 今回は割愛するが、rdiffを使ったアップデート方式を考えている。
  • アップデート前と後でファイルシステム(実際にはdocker imageのxxx.tar)の更新分を調べた。
  • 調べるために、shasumを利用したので、それを記事にテーマとする。

SHASUMとは

SHASUMはmessage digest algorithmsの一種で、詳細はブログに書いてあることを引用させていただく。

The shasum is used for computing SHA message digest, cryptographic checksum, or cryptographic hashcode. For those who don’t know, a message digest is a fixed size hash value of a message. A message digest is encrypted with a private key to form a digital signature.

  • shasumは、SHAメッセージダイジェスト、暗号化チェックサム(後述)、暗号化ハッシュコードの計算に使われる。
  • メッセージダイジェストとは署名付きのハッシュ値のメッセージ

There are two important aspects of a message digest:

  1. They produce hash values that are practically impossible to invert. Hence, they are unique. It is computationally impossible to find two files with the same MD(message digest) value.
  2. If we slightly change the original message, the new MD value will significantly change.
  • shasumはメッセージのたびに、署名が変更されることもあり、ユニークで改ざんされることがない

その他のmessage digest algorithms

message digest algorithmsには、

  • MD5
  • SHA-1 (16bit)
  • SHA-2
  • SHA-256 (128bit)
  • SHA-384 (192bit)
  • SHA-512 (256bit)

などがある。現在最も使われているのが、SHA-256でそれ以前はMD5SHA-1SHA-2などが使われていたが、脆弱性が明らかとなり、使われていない。

SHA-に続く数字はビット数と相関がある。

チェックサム

  • チェックサムとは平たく言えば、ファイルの整合性を確かめること
  • 手元にあるファイルと、それとをアップロードして再びダウンロードしたファイルの、整合性を測る手段
  • アップロードとダウンロードの過程でもしファイルが壊れていたら、それがわかるということです。
  • このチェックサムにSHASUMは活躍します

文字列のチェックサム

  • shasum XXXでXXXのハッシュ値が算出される。
~/❯❯❯ shasum  #Enter                                                                    
JAPAN #control + d
8a2697779846e2045e9507892110c97083915535  -

~/❯❯❯ shasum  #Enter     
JAPAN  #Enter 意図的に改行
       #control + d
5a44c5ea80dbe3875e15b7100487b5b99f25fcc9  -

fileのチェックサム

  • shasum XXX.yyyでファイルのハッシュ値が算出される。
~/❯❯❯ shasum test.py
6392e9d66e70c20f311bb6183fc5427d9ab72a12  test.py

おわりに

  • SHA は Secure Hash Algorithm のこと
  • xxx.tarのtarとは type archivesのことで、複数のファイルをまとめたもの
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?