See RFC 3174.
Unlike MessageDigest, this implementation includes the algorithm used by
sha1dc to detect cryptanalytic collision attacks against SHA-1, such
as the one used by SHAttered. See
sha1collisiondetection for more information.
When detectCollision is true (default), this implementation throws
org. from any digest
method if a potential collision was detected.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] | buffer
Buffer to accumulate partial blocks to 64 byte alignment. |
| private static final boolean | |
| private boolean | |
| private boolean | |
| private final SHA1Java. | |
| private final SHA1Java. | |
| private final SHA1Java. | |
| private long | length
Total number of bytes in the message. |
| private static final Logger | |
| private final SHA1Java. | |
| private final SHA1Java. | |
| private final int[] | |
| private final int[] |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| public byte[] | Returns: the bytes for the resulting hash.Implements abstract org. Finish the digest and return the resulting hash. |
| public void | digest(MutableObjectId
destination to copy the digest to. id)Implements abstract org. Finish the digest and return the resulting hash. |
| private static boolean | |
| private void | |
| public boolean | Returns: true if a likely collision was detected.Implements abstract org. Check if a collision was detected. |
| private void | |
| private void | |
| public SHA1 | Returns: this.Implements abstract org. Reset this instance to compute another hash. |
| private static int | |
| private static int | |
| private static int | |
| private static int | |
| public SHA1 | Returns: thisa boolean. detect)Implements abstract org. Enable likely collision detection. |
| public ObjectId | Returns: the ObjectId for the resulting hash.Implements abstract org. Finish the digest and return the resulting hash. |
| public void | update(byte
a byte. b)Implements abstract org. Update the digest computation by adding a byte. |
| public void | update(byte[]
input array of bytes. in)Implements abstract org. Update the digest computation by adding bytes to the message. |
| public void | update(byte[]
input array of bytes. in, int offset to start at from p, int in.number of bytes to hash. len)Implements abstract org. Update the digest computation by adding bytes to the message. |
| buffer | back to summary |
|---|---|
| private final byte[] buffer Buffer to accumulate partial blocks to 64 byte alignment. | |
| DETECT_COLLISIONS | back to summary |
|---|---|
| private static final boolean DETECT_COLLISIONS | |
| detectCollision | back to summary |
|---|---|
| private boolean detectCollision | |
| foundCollision | back to summary |
|---|---|
| private boolean foundCollision | |
| h | back to summary |
|---|---|
| private final SHA1Java. | |
| hIn | back to summary |
|---|---|
| private final SHA1Java. | |
| hTmp | back to summary |
|---|---|
| private final SHA1Java. | |
| length | back to summary |
|---|---|
| private long length Total number of bytes in the message. | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| state58 | back to summary |
|---|---|
| private final SHA1Java. | |
| state65 | back to summary |
|---|---|
| private final SHA1Java. | |
| w | back to summary |
|---|---|
| private final int[] w | |
| w2 | back to summary |
|---|---|
| private final int[] w2 | |
| SHA1Java | back to summary |
|---|---|
| pack-priv SHA1Java() | |
| compress | back to summary |
|---|---|
| private void compress(byte[] block, int p) | |
| compress | back to summary |
|---|---|
| private void compress() | |
| digest | back to summary |
|---|---|
| public byte[] digest() throws Sha1CollisionException Implements abstract org. Finish the digest and return the resulting hash.
Once
| |
| digest | back to summary |
|---|---|
| public void digest(MutableObjectId id) throws Sha1CollisionException Implements abstract org. Finish the digest and return the resulting hash.
Once
| |
| eq | back to summary |
|---|---|
| private static boolean eq(SHA1Java. | |
| finish | back to summary |
|---|---|
| private void finish() | |
| hasCollision | back to summary |
|---|---|
| public boolean hasCollision() Implements abstract org. Check if a collision was detected.
This method only returns an accurate result after the digest was obtained
through
| |
| initBlock | back to summary |
|---|---|
| private void initBlock(byte[] block, int p) | |
| recompress | back to summary |
|---|---|
| private void recompress(int t) | |
| reset | back to summary |
|---|---|
| public SHA1 reset() Implements abstract org. Reset this instance to compute another hash. | |
| s1 | back to summary |
|---|---|
| private static int s1(int a, int b, int c, int d, int w_t) | |
| s2 | back to summary |
|---|---|
| private static int s2(int a, int b, int c, int d, int w_t) | |
| s3 | back to summary |
|---|---|
| private static int s3(int a, int b, int c, int d, int w_t) | |
| s4 | back to summary |
|---|---|
| private static int s4(int a, int b, int c, int d, int w_t) | |
| setDetectCollision | back to summary |
|---|---|
| public SHA1 setDetectCollision(boolean detect) Implements abstract org. Enable likely collision detection.
Default is
May also be set by system property:
| |
| toObjectId | back to summary |
|---|---|
| public ObjectId toObjectId() throws Sha1CollisionException Implements abstract org. Finish the digest and return the resulting hash.
Once
| |
| update | back to summary |
|---|---|
| public void update(byte b) Implements abstract org. Update the digest computation by adding a byte.
| |
| update | back to summary |
|---|---|
| public void update(byte[] in) Implements abstract org. Update the digest computation by adding bytes to the message.
| |
| update | back to summary |
|---|---|
| public void update(byte[] in, int p, int len) Implements abstract org. Update the digest computation by adding bytes to the message.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv final void | |
| pack-priv final void | |
| pack-priv ObjectId |
| a | back to summary |
|---|---|
| pack-priv int a | |
| b | back to summary |
|---|---|
| pack-priv int b | |
| c | back to summary |
|---|---|
| pack-priv int c | |
| d | back to summary |
|---|---|
| pack-priv int d | |
| e | back to summary |
|---|---|
| pack-priv int e | |
| State | back to summary |
|---|---|
| private State() | |
| init | back to summary |
|---|---|
| pack-priv final void init() | |
| save | back to summary |
|---|---|
| pack-priv final void save(int a1, int b1, int c1, int d1, int e1) | |
| toObjectId | back to summary |
|---|---|
| pack-priv ObjectId toObjectId() | |