This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update AES interfaces, fix encrypt/decrypt/finish in certain cases
- Loading branch information
Adam Lippai
committed
Jun 3, 2018
1 parent
f193ecf
commit b6eb05d
Showing
11 changed files
with
127 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
import { AES } from './aes'; | ||
import { joinBytes } from '../other/utils'; | ||
|
||
export class AES_CBC extends AES { | ||
static encrypt(data: Uint8Array, key: Uint8Array, padding: boolean = true, iv?: Uint8Array): Uint8Array { | ||
return new AES_CBC(key, iv, padding).encrypt(data).result as Uint8Array; | ||
return new AES_CBC(key, iv, padding).encrypt(data); | ||
} | ||
|
||
static decrypt(data: Uint8Array, key: Uint8Array, padding: boolean = true, iv?: Uint8Array): Uint8Array { | ||
return new AES_CBC(key, iv, padding).decrypt(data).result as Uint8Array; | ||
return new AES_CBC(key, iv, padding).decrypt(data); | ||
} | ||
|
||
constructor(key: Uint8Array, iv?: Uint8Array, padding: boolean = true) { | ||
super(key, iv, padding, 'CBC'); | ||
} | ||
|
||
encrypt(data: Uint8Array): this { | ||
this.AES_Encrypt_process(data); | ||
return this.AES_Encrypt_finish(); | ||
encrypt(data: Uint8Array): Uint8Array { | ||
const r1 = this.AES_Encrypt_process(data); | ||
const r2 = this.AES_Encrypt_finish(); | ||
|
||
return joinBytes(r1, r2); | ||
} | ||
|
||
decrypt(data: Uint8Array): this { | ||
this.AES_Decrypt_process(data); | ||
return this.AES_Decrypt_finish(); | ||
decrypt(data: Uint8Array): Uint8Array { | ||
const r1 = this.AES_Decrypt_process(data); | ||
const r2 = this.AES_Decrypt_finish(); | ||
|
||
return joinBytes(r1, r2); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,26 +1,31 @@ | ||
import { AES } from './aes'; | ||
import { joinBytes } from '../other/utils'; | ||
|
||
export class AES_CFB extends AES { | ||
static encrypt(data: Uint8Array, key: Uint8Array, iv?: Uint8Array): Uint8Array { | ||
return new AES_CFB(key, iv).encrypt(data).result as Uint8Array; | ||
return new AES_CFB(key, iv).encrypt(data); | ||
} | ||
|
||
static decrypt(data: Uint8Array, key: Uint8Array, iv?: Uint8Array): Uint8Array { | ||
return new AES_CFB(key, iv).decrypt(data).result as Uint8Array; | ||
return new AES_CFB(key, iv).decrypt(data); | ||
} | ||
|
||
constructor(key: Uint8Array, iv?: Uint8Array) { | ||
super(key, iv, true, 'CFB'); | ||
delete this.padding; | ||
} | ||
|
||
encrypt(data: Uint8Array): this { | ||
this.AES_Encrypt_process(data); | ||
return this.AES_Encrypt_finish(); | ||
encrypt(data: Uint8Array): Uint8Array { | ||
const r1 = this.AES_Encrypt_process(data); | ||
const r2 = this.AES_Encrypt_finish(); | ||
|
||
return joinBytes(r1, r2); | ||
} | ||
|
||
decrypt(data: Uint8Array): this { | ||
this.AES_Decrypt_process(data); | ||
return this.AES_Decrypt_finish(); | ||
decrypt(data: Uint8Array): Uint8Array { | ||
const r1 = this.AES_Decrypt_process(data); | ||
const r2 = this.AES_Decrypt_finish(); | ||
|
||
return joinBytes(r1, r2); | ||
} | ||
} |
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
Oops, something went wrong.