Skip to content

Commit

Permalink
TKSS-996: Add native SM4 cipher benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshajiang committed Dec 18, 2024
1 parent 45762e6 commit 7225c9a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ public byte[] cbcPadding(DecrypterHolder holder) throws Exception {
return holder.decrypterCBCPadding.doFinal(holder.ciphertextCBCPadding);
}

@Benchmark
public byte[] cbcPaddingNative(DecrypterHolderNative holder) throws Exception {
return holder.decrypterCBCPadding.doFinal(holder.ciphertextCBCPadding);
}

@Benchmark
public byte[] cbcPaddingBC(DecrypterHolderBC holder) throws Exception {
return holder.decrypterCBCPadding.doFinal(holder.ciphertextCBCPadding);
Expand All @@ -301,6 +306,11 @@ public byte[] cbcNoPadding(DecrypterHolder holder) throws Exception {
return holder.decrypterCBCNoPadding.doFinal(holder.ciphertextCBCNoPadding);
}

@Benchmark
public byte[] cbcNoPaddingNative(DecrypterHolderNative holder) throws Exception {
return holder.decrypterCBCNoPadding.doFinal(holder.ciphertextCBCNoPadding);
}

@Benchmark
public byte[] cbcNoPaddingBC(DecrypterHolderBC holder) throws Exception {
return holder.decrypterCBCNoPadding.doFinal(holder.ciphertextCBCNoPadding);
Expand All @@ -311,6 +321,11 @@ public byte[] ecb(DecrypterHolder holder) throws Exception {
return holder.decrypterECBNoPadding.doFinal(holder.ciphertextECBNoPadding);
}

@Benchmark
public byte[] ecbNative(DecrypterHolderNative holder) throws Exception {
return holder.decrypterECBNoPadding.doFinal(holder.ciphertextECBNoPadding);
}

@Benchmark
public byte[] ecbBC(DecrypterHolderBC holder) throws Exception {
return holder.decrypterECBNoPadding.doFinal(holder.ciphertextECBNoPadding);
Expand All @@ -321,6 +336,11 @@ public byte[] ctr(DecrypterHolder holder) throws Exception {
return holder.decrypterCTRNoPadding.doFinal(holder.ciphertextCTRNoPadding);
}

@Benchmark
public byte[] ctrNative(DecrypterHolderNative holder) throws Exception {
return holder.decrypterCTRNoPadding.doFinal(holder.ciphertextCTRNoPadding);
}

@Benchmark
public byte[] ctrBC(DecrypterHolderBC holder) throws Exception {
return holder.decrypterCTRNoPadding.doFinal(holder.ciphertextCTRNoPadding);
Expand All @@ -331,6 +351,11 @@ public byte[] gcm(DecrypterHolder holder) throws Exception {
return holder.decrypterGCMNoPadding.doFinal(holder.ciphertextGCMNoPadding);
}

@Benchmark
public byte[] gcmNative(DecrypterHolderNative holder) throws Exception {
return holder.decrypterGCMNoPadding.doFinal(holder.ciphertextGCMNoPadding);
}

@Benchmark
public byte[] gcmBC(DecrypterHolderBC holder) throws Exception {
return holder.decrypterGCMNoPadding.doFinal(holder.ciphertextGCMNoPadding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ public byte[] cbcPadding(EncrypterHolder holder) throws Exception {
return holder.encrypterCBCPadding.doFinal(DATA);
}

@Benchmark
public byte[] cbcPaddingNative(EncrypterHolderNative holder) throws Exception {
return holder.encrypterCBCPadding.doFinal(DATA);
}

@Benchmark
public byte[] cbcPaddingBC(EncrypterHolderBC holder) throws Exception {
return holder.encrypterCBCPadding.doFinal(DATA);
Expand All @@ -199,6 +204,11 @@ public byte[] cbcNoPadding(EncrypterHolder holder) throws Exception {
return holder.encrypterCBCNoPadding.doFinal(DATA);
}

@Benchmark
public byte[] cbcNoPaddingNative(EncrypterHolderNative holder) throws Exception {
return holder.encrypterCBCNoPadding.doFinal(DATA);
}

@Benchmark
public byte[] cbcNoPaddingBC(EncrypterHolderBC holder) throws Exception {
return holder.encrypterCBCNoPadding.doFinal(DATA);
Expand All @@ -209,6 +219,11 @@ public byte[] ctr(EncrypterHolder holder) throws Exception {
return holder.encrypterCTRNoPadding.doFinal(DATA);
}

@Benchmark
public byte[] ctrNative(EncrypterHolderNative holder) throws Exception {
return holder.encrypterCTRNoPadding.doFinal(DATA);
}

@Benchmark
public byte[] ctrBC(EncrypterHolderBC holder) throws Exception {
return holder.encrypterCTRNoPadding.doFinal(DATA);
Expand All @@ -219,6 +234,11 @@ public byte[] ecb(EncrypterHolder holder) throws Exception {
return holder.encrypterECBNoPadding.doFinal(DATA);
}

@Benchmark
public byte[] ecbNative(EncrypterHolderNative holder) throws Exception {
return holder.encrypterECBNoPadding.doFinal(DATA);
}

@Benchmark
public byte[] ecbBC(EncrypterHolderBC holder) throws Exception {
return holder.encrypterECBNoPadding.doFinal(DATA);
Expand All @@ -229,6 +249,11 @@ public byte[] gcm(EncrypterHolder holder) throws Exception {
return holder.encrypterGCMNoPadding.doFinal(DATA);
}

@Benchmark
public byte[] gcmNative(EncrypterHolderNative holder) throws Exception {
return holder.encrypterGCMNoPadding.doFinal(DATA);
}

@Benchmark
public byte[] gcmBC(EncrypterHolderBC holder) throws Exception {
return holder.encrypterGCMNoPadding.doFinal(DATA);
Expand Down

0 comments on commit 7225c9a

Please sign in to comment.