LSH (hash function) explained

LSH is a cryptographic hash function designed in 2014 by South Korea to provide integrity in general-purpose software environments such as PCs and smart devices.[1] LSH is one of the cryptographic algorithms approved by the Korean Cryptographic Module Validation Program (KCMVP).And it is the national standard of South Korea (KS X 3262).

Specification

The overall structure of the hash function LSH is shown in the following figure.

The hash function LSH has the wide-pipe Merkle-Damgård structure with one-zeros padding.The message hashing process of LSH consists of the following three stages.

  1. Initialization:
    • One-zeros padding of a given bit string message.
    • Conversion to 32-word array message blocks from the padded bit string message.
    • Initialization of a chaining variable with the initialization vector.
  2. Compression:
    • Updating of chaining variables by iteration of a compression function with message blocks.
  3. Finalization:
    • Generation of an

n

-bit hash value from the final chaining variable.
  • function Hash function LSH
  • input: Bit string message

m

  • output: Hash value

h\in\{0,1\}n

  • procedure

  

One-zeros padding of

m

  

Generation of

t

message blocks

\{sf{M}(i)

t-1
\}
i=0

, where

t=\lceil

|m|+1
32w

\rceil

from the padded bit string

  

sf{CV}(0)\leftarrowsf{IV}

  

for

i=0

to

(t-1)

do

  

  

sf{CV}(i+1)\leftarrowrm{CF}(sf{CV}(i),sf{M}(i))

  

end for

  

h\leftarrow

(t)
rm{FIN}
n(sf{CV}

)

  

return

h

The specifications of the hash function LSH are as follows.

Hash function LSH specifications
AlgorithmDigest size in bits (

n

)
Number of step functions (

Ns

)
Chaining variable size in bitsMessage block size in bitsWord size in bits (

w

)
LSH-256-22422426512102432
LSH-256-256256
LSH-512-224224281024204864
LSH-512-256256
LSH-512-384384
LSH-512-512512

Initialization

Let

m

be a given bit string message.The given

m

is padded by one-zeros, i.e., the bit ‘1’ is appended to the end of

m

, and the bit ‘0’s are appended until a bit length of a padded message is

32wt

, where

t=\lceil(|m|+1)/32w\rceil

and

\lceilx\rceil

is the smallest integer not less than

x

.

Let

mp=m0\|m1\|\ldots\|m(32wt-1)

be the one-zeros-padded

32wt

-bit string of

m

.Then

mp

is considered as a

4wt

-byte array

ma=(m[0],\ldots,m[4wt-1])

, where

m[k]=m8k\|m(8k+1)\|\ldots\|m(8k+7)

for all

0\lek\le(4wt-1)

.The

4wt

-byte array

ma

converts into a

32t

-word array

sf{M}=(M[0],\ldots,M[32t-1])

as follows.

M[s]\leftarrowm[ws/8+(w/8-1)]\|\ldots\|m[ws/8+1]\|m[ws/8]

(0\les\le(32t-1))

From the word array

sf{M}

, we define the

t

32-word array message blocks

\{sf{M}(i)

t-1
\}
i=0

as follows.

sf{M}(i)\leftarrow(M[32i],M[32i+1],\ldots,M[32i+31])

(0\lei\le(t-1))

The 16-word array chaining variable

sf{CV}(0)

is initialized to the initialization vector

sf{IV}

.

sf{CV}(0)[l]\leftarrowsf{IV}[l]

(0\lel\le15)

The initialization vector

sf{IV}

is as follows.In the following tables, all values are expressed in hexadecimal form.
LSH-256-224 initialization vector

sf{IV}[0]

sf{IV}[1]

sf{IV}[2]

sf{IV}[3]

sf{IV}[4]

sf{IV}[5]

sf{IV}[6]

sf{IV}[7]

068608D362D8F7A7D76652AB4C600A43BDC40AA81ECA0B68DA1A89BE3147D354

sf{IV}[8]

sf{IV}[9]

sf{IV}[10]

sf{IV}[11]

sf{IV}[12]

sf{IV}[13]

sf{IV}[14]

sf{IV}[15]

707EB4F9F65B38626B0B2ABE56B8EC0ACF237286EE0D1727336365958BB8D05F
LSH-256-256 initialization vector

sf{IV}[0]

sf{IV}[1]

sf{IV}[2]

sf{IV}[3]

sf{IV}[4]

sf{IV}[5]

sf{IV}[6]

sf{IV}[7]

46A10F1FFDDCE486B41443A8198E6B9D3304388DB0F5A3C7B36061C47ADBD553

sf{IV}[8]

sf{IV}[9]

sf{IV}[10]

sf{IV}[11]

sf{IV}[12]

sf{IV}[13]

sf{IV}[14]

sf{IV}[15]

105D53782F74DE545C2F2D95F2553FBE8051357A138668C847AA4484E01AFB41
LSH-512-224 initialization vector

sf{IV}[0]

sf{IV}[1]

sf{IV}[2]

sf{IV}[3]

0C401E9FE8813A554A5F446268FD3D35FF13E452334F612AF8227661037E354A

sf{IV}[4]

sf{IV}[5]

sf{IV}[6]

sf{IV}[7]

A5F223723C9CA29D95D965A11AED397901E23835B9AB02CC52D49CBAD5B30616

sf{IV}[8]

sf{IV}[9]

sf{IV}[10]

sf{IV}[11]

9E5C2027773F4ED366A5C8801925B70122BBC85B4C6779D9C13171A42C559C23

sf{IV}[12]

sf{IV}[13]

sf{IV}[14]

sf{IV}[15]

31E2B67D25BE3813D522C4DEED8E4D83A79F5509B43FBAFEE00D2CD88B4B6C6A
LSH-512-256 initialization vector

sf{IV}[0]

sf{IV}[1]

sf{IV}[2]

sf{IV}[3]

6DC57C33DF989423D8EA7F6E8342C19976DF8356F8603AC440F1B44DE838223A

sf{IV}[4]

sf{IV}[5]

sf{IV}[6]

sf{IV}[7]

39FFE7CFC31484CD39C4326CC52815488A2FF85A346045D8FF202AA46DBDD61E

sf{IV}[8]

sf{IV}[9]

sf{IV}[10]

sf{IV}[11]

CF785B3CD5FCDB8B1F0323B64A8150BFFF75D972F29EA3552E567F30BF1CA9E1

sf{IV}[12]

sf{IV}[13]

sf{IV}[14]

sf{IV}[15]

B596875BF8FF6DBAFCCA39B089EF4615ECFF4017D020B4B67E77384C772ED802
LSH-512-384 initialization vector

sf{IV}[0]

sf{IV}[1]

sf{IV}[2]

sf{IV}[3]

53156A66292808F6B2C4F362B204C2BCB84B7213BFA05C4E976CEB7C1B299F73

sf{IV}[4]

sf{IV}[5]

sf{IV}[6]

sf{IV}[7]

DF0CC63C0570AE97DA4441BAA486CE3F6559F5D9B5F2ACC222DACF19B4B52A16

sf{IV}[8]

sf{IV}[9]

sf{IV}[10]

sf{IV}[11]

BBCDACEFDE80953AC9891A2879725B3E7C9FE6330237E440A30BA550553F7431

sf{IV}[12]

sf{IV}[13]

sf{IV}[14]

sf{IV}[15]

BB08043FB34E3E30A0DEC48D54618EAD150317267464BC5732D1501FDE63DC93
LSH-512-512 initialization vector

sf{IV}[0]

sf{IV}[1]

sf{IV}[2]

sf{IV}[3]

ADD50F3C7F07094EE3F3CEE8F9418A4FB527ECDE5B3D0AE92EF6DEC68076F501

sf{IV}[4]

sf{IV}[5]

sf{IV}[6]

sf{IV}[7]

8CB994CAE5ACA216FBB9EAE4BBA48CC7650A526174725FEA1F9A61A73F8D8085

sf{IV}[8]

sf{IV}[9]

sf{IV}[10]

sf{IV}[11]

B6607378173B539B1BC99853B0C0B9EDDF727FC19B182D47DBEF360CF893A457

sf{IV}[12]

sf{IV}[13]

sf{IV}[14]

sf{IV}[15]

4981F5E570147E80D00C4490CA7D3E305D73940C0E4AE1EC894085E2EDB2D819

Compression

In this stage, the

t

32-word array message blocks

\{sf{M}(i)

t-1
\}
i=0

, which are generated from a message

m

in the initialization stage, are compressed by iteration of compression functions.The compression function

rm{CF}:l{W}16 x l{W}32l{W}16

has two inputs; the

i

-th 16-word chaining variable

sf{CV}(i)

and the

i

-th 32-word message block

sf{M}(i)

.And it returns the

(i+1)

-th 16-word chaining variable

sf{CV}(i+1)

.Here and subsequently,

l{W}t

denotes the set of all

t

-word arrays for

t\ge1

.

The following four functions are used in a compression function:

rm{MsgExp}:l{W}32l{W}16(Ns+1)

rm{MsgAdd}:l{W}16 x l{W}16l{W}16

rm{Mix}j:l{W}16l{W}16

rm{WordPerm}:l{W}16l{W}16

The overall structure of the compression function is shown in the following figure.

In a compression function, the message expansion function

rm{MsgExp}

generates

(Ns+1)

16-word array sub-messages

\{

(i)
sf{M}
j
Ns
\}
j=0

from given

sf{M}(i)

.Let

sf{T}=(T[0],\ldots,T[15])

be a temporary 16-word array set to the

i

-th chaining variable

sf{CV}(i)

.The

j

-th step function

rm{Step}j

having two inputs

sf{T}

and
(i)
sf{M}
j

updates

sf{T}

, i.e.,

sf{T}\leftarrowrm{Step}j\left(

(i)
sf{T},sf{M}
j

\right)

.All step functions are proceeded in order

j=0,\ldots,Ns-1

.Then one more

rm{MsgAdd}

operation by
(i)
sf{M}
Ns

is proceeded, and the

(i+1)

-th chaining variable

sf{CV}(i+1)

is set to

sf{T}

.The process of a compression function in detail is as follows.
  • function Compression function

rm{CF}

  • input: The

i

-th chaining variable

sf{CV}(i)\inl{W}16

and the

i

-th message block

sf{M}(i)\inl{W}32

  • output: The

(i+1)

-th chaining variable

sf{CV}(i+1)\inl{W}16

  • procedure

  

\{

(i)
sf{M}
j
Ns
\}
j=0

\leftarrowrm{MsgExp}\left(sf{M}(i)\right)

  

sf{T}\leftarrowsf{CV}(i)

  

for

j=0

to

(Ns-1)

do

  

  

sf{T}\leftarrowrm{Step}j\left(

(i)
sf{T},sf{M}
j

\right)

  

end for

  

sf{CV}(i+1)\leftarrowrm{MsgAdd}\left(

(i)
sf{T},sf{M}
Ns

\right)

  

return

sf{CV}(i+1)

Here the

j

-th step function

rm{Step}j:l{W}16 x l{W}16l{W}16

is as follows.

rm{Step}j:=rm{WordPerm}\circrm{Mix}j\circrm{MsgAdd}

(0\lej\le(Ns-1))

The following figure shows the

j

-th step function

rm{Step}j

of a compression function.

Message Expansion Function MsgExp

Let

sf{M}(i)=(M(i)[0],\ldots,M(i)[31])

be the

i

-th 32-word array message block.The message expansion function

rm{MsgExp}

generates

(Ns+1)

16-word array sub-messages

\{

(i)
sf{M}
j
Ns
\}
j=0

from a message block

sf{M}(i)

.The first two sub-messages
(i)
sf{M}
0

=(

(i)
M
0

[0],\ldots,

(i)
M
0

[15])

and
(i)
sf{M}
1

=(

(i)
M
1

[0],\ldots,

(i)
M
1

[15])

are defined as follows.
(i)
sf{M}
0

\leftarrow(M(i)[0],M(i)[1],\ldots,M(i)[15])

(i)
sf{M}
1

\leftarrow(M(i)[16],M(i)[17],\ldots,M(i)[31])

The next sub-messages

\{

(i)
sf{M}
j

=(

(i)
M
j

[0],\ldots,

(i)
M
j

[15])

Ns
\}
j=2

are generated as follows.
(i)
sf{M}
j

[l]\leftarrow

(i)
sf{M}
j-1

[l]

(i)
\boxplussf{M}
j-2

[\tau(l)]

(0\lel\le15, 2\lej\leNs)

Here

\tau

is the permutation over

Z16

defined as follows.
The permutation

\tau:Z16Z16

l

0123456789101112131415

\tau(l)

3201745611108915121314

Message Addition Function MsgAdd

For two 16-word arrays

sf{X}=(X[0],\ldots,X[15])

and

sf{Y}=(Y[0],\ldots,Y[15])

, the message addition function

rm{MsgAdd}:l{W}16 x l{W}16l{W}16

is defined as follows.

rm{MsgAdd}(sf{X},sf{Y}):=(X[0]Y[0],\ldots,X[15]Y[15])

Mix Function Mix

The

j

-th mix function

rm{Mix}j:l{W}16l{W}16

updates the 16-word array

sf{T}=(T[0],\ldots,T[15])

by mixing every two-word pair;

T[l]

and

T[l+8]

for

(0\lel<8)

.For

0\lej<Ns

, the mix function

rm{Mix}j

proceeds as follows.

(T[l],T[l+8])\leftarrowrm{Mix}j,l(T[l],T[l+8])

(0\lel<8)

Here

rm{Mix}j,l

is a two-word mix function.Let

X

and

Y

be words.The two-word mix function

rm{Mix}j,l:l{W}2l{W}2

is defined as follows.
  • function Two-word mix function

rm{Mix}j,l

  • input: Words

X

and

Y

  • output: Words

X

and

Y

  • procedure

  

X\leftarrowX\boxplusY

   X\leftarrow

\lll\alphaj
X

  

X\leftarrowXSCj[l]

  

Y\leftarrowX\boxplusY

   Y\leftarrow

\lll\betaj
Y

  

X\leftarrowX\boxplusY

   Y\leftarrow

\lll\gammal
Y

  

return

X

,

Y

;

The two-word mix function

rm{Mix}j,l

is shown in the following figure.

The bit rotation amounts

\alphaj

,

\betaj

,

\gammal

used in

rm{Mix}j,l

are shown in the following table.
Bit rotation amounts

\alphaj

,

\betaj

, and

\gammal

w

j

\alphaj

\betaj

\gamma0

\gamma1

\gamma2

\gamma3

\gamma4

\gamma5

\gamma6

\gamma7

32even291081624241680
odd517
64even235901632488244056
odd73

The

j

-th 8-word array constant

sf{SC}j=(SCj[0],\ldots,SCj[7])

used in

rm{Mix}j,l

for

0\lel<8

is defined as follows.The initial 8-word array constant

sf{SC}0=(SC0[0],\ldots,SC0[7])

is defined in the following table.For

1\lej<Ns

, the

j

-th constant

sf{SC}j=(SCj[0],\ldots,SCj[7])

is generated by

SCj[l]\leftarrowSCj-1[l]\boxplusSCj-1[l]\lll

for

0\lel<8

.
Initial 8-word array constant

sf{SC}0

w=32

w=64

SC0[0]

917caf9097884283c938982a

SC0[1]

6c1b10a2ba1fca93533e2355

SC0[2]

6f352943c519a2e87aeb1c03

SC0[3]

cf7782439a0fc95462af17b1

SC0[4]

2ceb7472fc3dda8ab019a82b

SC0[5]

29e96ff202825d079a895407

SC0[6]

8a9ba42879f2d0a7ee06a6f7

SC0[7]

2eeb2642d76d15eed9fdf5fe

Word-Permutation Function WordPerm

Let

sf{X}=(X[0],\ldots,X[15])

be a 16-word array.The word-permutation function

rm{WordPerm}:l{W}16l{W}16

is defined as follows.

rm{WordPerm}(sf{X})=(X[\sigma(0)],\ldots,X[\sigma(15)])

Here

\sigma

is the permutation over

Z16

defined by the following table.
The permutation

\sigma:Z16Z16

l

0123456789101112131415

\sigma(l)

6457121514132013811109

Finalization

The finalization function

rm{FIN}n:l{W}16\{0,1\}n

returns

n

-bit hash value

h

from the final chaining variable

sf{CV}(t)=(CV(t)[0],\ldots,CV(t)[15])

.When

sf{H}=(H[0],\ldots,H[7])

is an 8-word variable and

sf{h}sf{b}=(hb[0],\ldots,hb[w-1])

is a

w

-byte variable, the finalization function

rm{FIN}n

performs the following procedure.

H[l]\leftarrowCV(t)[l]CV(t)[l+8]

(0\lel\le7)

hb[s]\leftarrowH[\lfloor8s/w\rfloor

\ggg(8s\modw)
]
[7:0]

(0\les\le(w-1))

h\leftarrow(hb[0]\|\ldots\|hb[w-1])[0:n-1]

Here,

X[i:j]

denotes

xi\|xi-1\|\ldots\|xj

, the sub-bit string of a word

X

for

i\gej

.And

x[i:j]

denotes

xi\|xi+1\|\ldots\|xj

, the sub-bit string of a

l

-bit string

x=x0\|x1\|\ldots\|xl-1

for

i\lej

.

Security

LSH is secure against known attacks on hash functions up to now.LSH is collision-resistant for

q<2n/2

and preimage-resistant and second-preimage-resistant for

q<2n

in the ideal cipher model, where

q

is a number of queries for LSH structure.LSH-256 is secure against all the existing hash function attacks when the number of steps is 13 or more, while LSH-512 is secure if the number of steps is 14 or more.Note that the steps which work as security margin are 50% of the compression function.

Performance

LSH outperforms SHA-2/3 on various software platforms.The following table shows the speed performance of 1MB message hashing of LSH on several platforms.

1MB message hashing speed of LSH (cycles/byte)
PlatformP1P2P3P4P5P6P7P8
LSH-256-

n

3.603.865.263.8911.1715.0315.2814.84
LSH-512-

n

2.395.047.765.528.9418.7619.0018.10

The following table is the comparison at the platform based on Haswell, LSH is measured on Intel Core i7-4770k @ 3.5 GHz quad core platform, and others are measured on Intel Core i5-4570S @ 2.9 GHz quad core platform.

Speed benchmark of LSH, SHA-2 and the SHA-3 finalists at the platform based on Haswell CPU (cycles/byte)
AlgorithmMessage size in bytes
long4,0961,536576648
LSH-256-2563.603.713.904.088.1965.37
Skein-512-2565.015.585.866.4913.12104.50
Blake-2566.617.637.879.0516.5872.50
Grøstl-2569.4810.6812.1813.7137.94227.50
Keccak-25610.5610.529.9011.9923.38187.50
SHA-25610.8211.9112.2613.5124.88106.62
JH-25614.7015.5015.9417.0631.94257.00
LSH-512-5122.392.542.793.3110.8185.62
Skein-512-5124.675.515.806.4413.59108.25
Blake-5124.966.176.827.3814.81116.50
SHA-5127.658.248.699.0317.22138.25
Grøstl-51212.7815.4417.3017.9951.72417.38
JH-51214.2515.6616.1417.3432.69261.00
Keccak-51216.3617.8618.4620.3521.56171.88

The following table is measured on Samsung Exynos 5250 ARM Cortex-A15 @ 1.7 GHz dual core platform.

Speed benchmark of LSH, SHA-2 and the SHA-3 finalists at the platform based on Exynos 5250 ARM Cortex-A15 CPU (cycles/byte)
AlgorithmMessage size in bytes
long4,0961,536576648
LSH-256-25611.1711.5312.1612.6322.42192.68
Skein-512-25615.6416.7218.3322.6875.75609.25
Blake-25617.9419.1120.8825.4483.94542.38
SHA-25619.9121.1423.0328.1390.89578.50
JH-25634.6636.0638.1043.51113.92924.12
Keccak-25636.0338.0140.5448.13125.001000.62
Grøstl-25640.7042.7646.0354.94167.521020.62
LSH-512-5128.949.5610.5512.2838.82307.98
Blake-51213.4614.8216.8820.9877.53623.62
Skein-512-51215.6116.7318.3522.5675.59612.88
JH-51234.8836.2638.3644.01116.41939.38
SHA-51244.1346.4149.9754.55135.591088.38
Keccak-51263.3164.5967.8577.21121.28968.00
Grøstl-512131.35138.49150.15166.54446.533518.00

Test vectors

Test vectors for LSH for each digest length are as follows.All values are expressed in hexadecimal form.

LSH-256-224("abc") =

F7 C5 3B A4 03 4E 70 8E 74 FB A4 2E 55 99 7C A5 12 6B B7 62 36 88 F8 53 42 F7 37 32

LSH-256-256("abc") =

5F BF 36 5D AE A5 44 6A 70 53 C5 2B 57 40 4D 77 A0 7A 5F 48 A1 F7 C1 96 3A 08 98 BA 1B 71 47 41

LSH-512-224("abc") =

D1 68 32 34 51 3E C5 69 83 94 57 1E AD 12 8A 8C D5 37 3E 97 66 1B A2 0D CF 89 E4 89

LSH-512-256("abc") =

CD 89 23 10 53 26 02 33 2B 61 3F 1E C1 1A 69 62 FC A6 1E A0 9E CF FC D4 BC F7 58 58 D8 02 ED EC

LSH-512-384("abc") =

5F 34 4E FA A0 E4 3C CD 2E 5E 19 4D 60 39 79 4B 4F B4 31 F1 0F B4 B6 5F D4 5E 9D A4 EC DE 0F 27 B6 6E 8D BD FA 47 25 2E 0D 0B 74 1B FD 91 F9 FE

LSH-512-512("abc") =

A3 D9 3C FE 60 DC 1A AC DD 3B D4 BE F0 A6 98 53 81 A3 96 C7 D4 9D 9F D1 77 79 56 97 C3 53 52 08 B5 C5 72 24 BE F2 10 84 D4 20 83 E9 5A 4B D8 EB 33 E8 69 81 2B 65 03 1C 42 88 19 A1 E7 CE 59 6D

Implementations

LSH is free for any use public or private, commercial or non-commercial.The source code for distribution of LSH implemented in C, Java, and Python can be downloaded from KISA's cryptography use activation webpage.[2]

KCMVP

LSH is one of the cryptographic algorithms approved by the Korean Cryptographic Module Validation Program (KCMVP).[3]

Standardization

LSH is included in the following standard.

Notes and References

  1. Book: Kim . Dong-Chan . Hong . Deukjo . Lee . Jung-Keun . Kim . Woo-Hwan . Kwon . Daesung . Information Security and Cryptology - ICISC 2014 . LSH: A New Fast Secure Hash Function Family . Lecture Notes in Computer Science . 2015 . 8949 . Springer International Publishing . 978-3-319-15943-0 . 286–313 . 10.1007/978-3-319-15943-0_18 . https://link.springer.com/chapter/10.1007/978-3-319-15943-0_18 . en.
  2. Web site: KISA 암호이용활성화 - 암호알고리즘 소스코드. seed.kisa.or.kr.
  3. Web site: KISA 암호이용활성화 - 개요. seed.kisa.or.kr.
  4. Web site: Korean Standards & Certifications (in Korean) .