Experiments with RSA encryption

This commit is contained in:
RainLoop Team 2014-07-25 02:28:10 +04:00
parent bbcbfdc150
commit 777d014403
36 changed files with 2272 additions and 7995 deletions

View file

@ -73,6 +73,31 @@ Utils.isNonEmptyArray = function (aValue)
return Utils.isArray(aValue) && 0 < aValue.length;
};
/**
* @param {string} aValue
* @param {string} sKey
* @param {string} sLongKey
* @return {string|boolean}
*/
Utils.rsaEncode = function (sValue, sHash, sKey, sLongKey)
{
if (window.crypto && window.crypto.getRandomValues && window.RSAKey && sHash && sKey && sLongKey)
{
var oRsa = new window.RSAKey();
oRsa.setPublic(sLongKey, sKey);
sValue = oRsa.encrypt(Utils.fakeMd5() + ':' + sValue + ':' + Utils.fakeMd5());
if (false !== sValue)
{
return 'rsa:' + sHash + ':' + sValue;
}
}
return false;
};
Utils.rsaEncode.supported = !!(window.crypto && window.crypto.getRandomValues && window.RSAKey);
/**
* @param {string} sPath
* @param {*=} oObject
@ -462,7 +487,7 @@ Utils.replySubjectAdd = function (sPrefix, sSubject)
for (iIndex = 0; iIndex < aParts.length; iIndex++)
{
sTrimmedPart = Utils.trim(aParts[iIndex]);
if (!bDrop &&
if (!bDrop &&
(/^(RE|FWD)$/i.test(sTrimmedPart) || /^(RE|FWD)[\[\(][\d]+[\]\)]$/i.test(sTrimmedPart))
)
{
@ -470,7 +495,7 @@ Utils.replySubjectAdd = function (sPrefix, sSubject)
{
bRe = !!(/^RE/i.test(sTrimmedPart));
}
if (!bFwd)
{
bFwd = !!(/^FWD/i.test(sTrimmedPart));