Skip to content

Fix Typo (tmp.length() -> tmp.length) #1111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bigdale123
Copy link

So I think I encountered a typo in the aes.js lib file. On line 203, the length of tmp is found using tmp.length(). But,
a) this results in a type error complaining that tmp.length() is not a function (See Issue #552
b) it is done the correct way (at least, as far as I can tell) not 10 lines earlier. I have provided an excerpt from aes.js:

183 |  if(typeof key === 'string' &&
184 |    (key.length === 16 || key.length === 24 || key.length === 32)) {
185 |    // convert key string into byte buffer
186 |    key = forge.util.createBuffer(key);
187 |  } else if(forge.util.isArray(key) &&
188 |    (key.length === 16 || key.length === 24 || key.length === 32)) {
189 |    // convert key integer array into byte buffer
190 |    tmp = key;
191 |    key = forge.util.createBuffer();
192 |    for(var i = 0; i < tmp.length; ++i) {
193 |      key.putByte(tmp[i]);
194 |    }
195 |  }
196 |
197 |  // convert key byte buffer into 32-bit integer array
198 |  if(!forge.util.isArray(key)) {
199 |    tmp = key;
200 |    key = [];
201 |
202 |    // key lengths of 16, 24, 32 bytes allowed
203 |    var len = tmp.length();
204 |    if(len === 16 || len === 24 || len === 32) {
205 |      len = len >>> 2;
206 |      for(var i = 0; i < len; ++i) {
207 |        key.push(tmp.getInt32());
208 |      }
209 |    }
210 |  }

So this pull request addresses that by chaning line 203 from var len = tmp.length(); to var len = tmp.length;
Hope i'm not wrong about it, but it seems like a no brainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant