-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/encrypt_padding' into 'master'
Feat/encrypt padding See merge request TankerHQ/sdk-android!264
- Loading branch information
Showing
7 changed files
with
209 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.tanker.api | ||
|
||
/** | ||
* Padding control for data encryption. | ||
*/ | ||
sealed class Padding(internal val native_value: Int) { | ||
/** | ||
* Allowed values for Padding variables | ||
*/ | ||
companion object { | ||
/** | ||
* This is the default option. | ||
*/ | ||
@JvmStatic val auto : Padding = Auto | ||
|
||
/** | ||
* Disables padding. | ||
*/ | ||
@JvmStatic val off : Padding = Off | ||
|
||
/** | ||
* Pads the data up to a multiple of value before encryption. | ||
* To disable padding, use Off(). | ||
* @param value A >= 2 integer. | ||
*/ | ||
@JvmStatic fun step(value: Int): Padding = Step(value) | ||
} | ||
|
||
private object Auto : Padding(0) | ||
private object Off : Padding(1) | ||
|
||
private class Step(value: Int) : Padding(value) { | ||
init { | ||
if (value <= 1) | ||
throw IllegalArgumentException("Invalid padding step, the value must be >= 2.") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters