RSA密钥对测试

我对 RSA密钥对生成器 进行了一些修改,指定生成公钥的前半部分内容,
随机生成第一个素数作为因数后用目标值限制另一个因数的范围取素数,
在两个因数大小相近的情况下大概有一半的空间是不可控内容,
缩小第一个因数可以减少不可控的部分但会降低密钥的安全性
密钥使用例:

(e=>e.c.importKey(
  'jwk',e.data
  ,{name:'RSASSA-PKCS1-v1_5',hash:'SHA-256'},!0,['sign']
).then(k=>e.c.sign(k.algorithm,k,new Uint8Array([1,2,3])))
.then(e=>(
  console.log('sign: ',new Uint8Array(e))
)).then(async()=>{
  var pk=await e.c.importKey(
    'jwk',e.data
    ,{name:'RSA-OAEP',hash:'SHA-256'},!0,['decrypt']
  ),bk=await e.c.importKey(
    'jwk',{kty:'RSA',e:'AQAB',n:e.data.n}
    ,{name:'RSA-OAEP',hash:'SHA-256'},!0,['encrypt']
  ),ec=await e.c.encrypt(bk.algorithm,bk,new Uint8Array([1,2,3]))
  ,dc=await e.c.decrypt(pk.algorithm,pk,ec)
  console.log('enc: ',new Uint8Array(ec))
  console.log('dec: ',new Uint8Array(dc))
})
)({
  c:'object'===typeof crypto&&crypto&&'object'===typeof crypto.subtle&&crypto.subtle||{
    importKey(){throw new Error('Subtlecrypto is not supported or this page is not a SecureContext page.')}
  },data:{
    "e": "AQAB",
    "d": "KchEtmNoKPV-SQtiGCwgt22BdgzC1stiGCwgt22BdgzC1stiGCwgt22BdgzC1stiGCwgt22BdgzC1stiGCwgn0ocrfgZP0iegcFcwN8aAqraFbPQGANDIp096-SS1CVLJye7u627Pnucstvxl6i_tszfLcrZaklydMfl6d40Djk",
    "n": "RSA-public-key----------------------------------------------------------------------1Xx_oaFd-BmFTkj_PlezN51sF3pH58kzvHmw1N4QCf6YA3N4qeUPWExOQa8m5I9ssfZZw42wgW_f5p8ZK5P_ndM",
    "p": "AUXTHxBAx8uo1xfB5vkcZSK-k9stWzS4UdMLwm1ftR5va1bLKxiKiexr6R2KsMbZ_igM6dGiK1OChlshTn6J3Vc",
    "q": "Nk_qGRI7c-7rjrKGVWZzoS7gnIbHNlJ4iVcbdWvRUtwotI3iamyzFZBfTHBX-_4ySwbtnPak1OqvI2l4R9X55Q",
    "dp": "LdQOMHkMISc0adEKLcvCpepsXY25oGa0i5zB0iR-EzPUwzZ8b009LRXYiiEx0CZlSzjVwniu42Yeg77hjYbSrQ",
    "dq": "MW-aMMnkrckKRm__UFqZ41vs_Oy9BZgZuUE9cCr8dISK1JXVQnPAql8oL0aO_4NIOfyLafUi4d7gHcaRwilldQ",
    "qi": "XyjNGy9HACAhNGT93uIpC9qxgs_iOEfjuyhJd1140hl75uOHvKINd7ZfnYamvjfw4qg6dCZaJFzZPe6cKiLnbg",
    "kty": "RSA"
  }
})

一个问题:像这样的1024位RSA密钥对足够安全吗?

这我也不知道了hhhh

新建了一个“作品分享“区可以贴这些内容。