Skip to content

Commit

Permalink
delete duplicated test case
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Apr 7, 2024
1 parent 02dc780 commit b867dab
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/jsrsasign_patch_test.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,8 @@
const test = require('tape')
const rs = require('jsrsasign')
const KJUR = rs.KJUR
const C = rs.CryptoJS
require('./jsrsasign_patch').patch()

test('test sm4-cbc with default mode', (t) => {
const cases = [
{
key: '30313233343536373839414243444546',
iv: '30313233343536373839414243444546',
plaintext: '48656c6c6f20576f726c64',
ciphertext: '0a67062f0cd2dce26a7b978ebf2134f9'
},
{
key: '30313233343536373839414243444546',
iv: '30313233343536373839414243444546',
plaintext:
'48656c6c6f20576f726c642048656c6c6f20576f726c642048656c6c6f20576f726c642048656c6c6f20576f726c6464',
ciphertext:
'd31e3683e4fc9b516a2c0f983676a9eb1fdcc32af38408978157a2065de34c6a068d0fef4e2bfab4bcaba66441fde0fe92c164eca170247572de1202952ec727'
},
{
key: '0123456789abcdeffedcba9876543210',
iv: '00000000000000000000000000000000',
plaintext: '0123456789abcdeffedcba9876543210',
ciphertext:
'681edf34d206965e86b3e94f536e4246677d307e844d7aa24579d556490dc7aa'
}
]
for (const c of cases) {
const ciphertext = C.SM4.encrypt(
C.enc.Hex.parse(c.plaintext),
C.enc.Hex.parse(c.key),
{ iv: C.enc.Hex.parse(c.iv) }
).ciphertext.toString()

t.equal(ciphertext, c.ciphertext)
const plaintext = C.SM4.decrypt(
{ ciphertext: C.enc.Hex.parse(c.ciphertext) },
C.enc.Hex.parse(c.key),
{ iv: C.enc.Hex.parse(c.iv) }
)
t.equal(plaintext.toString(), c.plaintext)
}
t.end()
})

test('test sm4-cbc with KJUR.crypto.Cipher', (t) => {
const cases = [
{
Expand Down

0 comments on commit b867dab

Please sign in to comment.