summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_crypto/crypto_browserify/browserify_aes/incr32.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/_crypto/crypto_browserify/browserify_aes/incr32.js')
-rw-r--r--ext/node/polyfills/_crypto/crypto_browserify/browserify_aes/incr32.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/node/polyfills/_crypto/crypto_browserify/browserify_aes/incr32.js b/ext/node/polyfills/_crypto/crypto_browserify/browserify_aes/incr32.js
new file mode 100644
index 000000000..65172eefb
--- /dev/null
+++ b/ext/node/polyfills/_crypto/crypto_browserify/browserify_aes/incr32.js
@@ -0,0 +1,19 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+// Copyright 2014-2017 browserify-aes contributors. All rights reserved. MIT license.
+// Copyright 2013 Maxwell Krohn. All rights reserved. MIT license.
+// Copyright 2009-2013 Jeff Mott. All rights reserved. MIT license.
+
+export function incr32(iv) {
+ let len = iv.length;
+ let item;
+ while (len--) {
+ item = iv.readUInt8(len);
+ if (item === 255) {
+ iv.writeUInt8(0, len);
+ } else {
+ item++;
+ iv.writeUInt8(item, len);
+ break;
+ }
+ }
+}