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