4c95e330c468a40d8293cf395c7f7d7ca89cead5
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / resources / rsaauth.js
1 function tx_rsaauth_encrypt() {
2 var rsa = new RSAKey();
3 rsa.setPublic(document.loginform.n.value, document.loginform.e.value);
4
5 var username = document.loginform.username.value;
6 var password = document.loginform.p_field.value;
7
8 var res = rsa.encrypt(password);
9
10 // Remove all plaintext-data
11 document.loginform.p_field.value = "";
12 document.loginform.e.value = "";
13 document.loginform.n.value = "";
14
15 if (res) {
16 document.loginform.userident.value = 'rsa:' + hex2b64(res);
17 }
18 }
19
20 function tx_rsaauth_feencrypt(form) {
21 // check if the form was already sent (see #40085)
22 if (form.pass.value.match(/^rsa:/) || form.n.value == '' || form.e.value == '') {
23 return;
24 }
25 var rsa = new RSAKey();
26 rsa.setPublic(form.n.value, form.e.value);
27
28 var username = form.user.value;
29 var password = form.pass.value;
30
31 var res = rsa.encrypt(password);
32
33 // Remove all plaintext-data. This will also prevent plain text authentication.
34 form.pass.value = "";
35 form.e.value = "";
36 form.n.value = "";
37
38 if (res) {
39 form.pass.value = 'rsa:' + hex2b64(res);
40 }
41 }
42
43 function tx_rsaauth_encryptUserSetup() {
44
45 var rsa = new RSAKey();
46 rsa.setPublic(document.usersetup.n.value, document.usersetup.e.value);
47
48 var password = document.getElementById('field_password').value;
49 var password2 = document.getElementById('field_password2').value;
50
51 if (password || password2) {
52 var res = rsa.encrypt(password);
53 var res2 = rsa.encrypt(password2);
54 if (res && res2) {
55 document.getElementById('field_password').value = 'rsa:' + hex2b64(res);
56 document.getElementById('field_password2').value = 'rsa:' + hex2b64(res2);
57 }
58 } return false;
59 }