Class RSACore


  • final class RSACore
    extends java.lang.Object
    Operaciones con claves privadas RSA. No se soporta CRT (Chinese Remainder Theorem). Esta clase no realiza rellenos, estos deben hacerse externamente. Nota: Las claves RSA deben ser de al menos 512 bits.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private RSACore()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static byte[] convert​(byte[] b, int ofs, int len)  
      private static byte[] crypt​(byte[] msg, java.math.BigInteger n, java.math.BigInteger exp)
      Operación general de cifrado RSA (un modPow()).
      private static RSACore.BlindingRandomPair getBlindingRandomPair​(java.math.BigInteger e, java.math.BigInteger d, java.math.BigInteger n)  
      (package private) static int getByteLength​(java.math.BigInteger b)
      Return the number of bytes required to store the magnitude byte[] of this BigInteger.
      (package private) static int getByteLength​(java.security.interfaces.RSAKey key)
      Devuelve el número de octetos necesarios para almacenar el módulo de una clave RSA.
      private static java.math.BigInteger parseMsg​(byte[] msg, java.math.BigInteger n)
      Parse the msg into a BigInteger and check against the modulus n.
      private static byte[] priCrypt​(byte[] msg, java.math.BigInteger n, java.math.BigInteger exp)
      RSA non-CRT private key operations.
      (package private) static byte[] rsa​(byte[] msg, java.security.interfaces.RSAPrivateKey key)
      Ejecuta un cifrado RSA con una clave privada.
      (package private) static byte[] rsa​(byte[] msg, java.security.interfaces.RSAPublicKey key)
      Ejecuta un cifrado RSA con una clave pública.
      private static byte[] toByteArray​(java.math.BigInteger bi, int len)
      Return the encoding of this BigInteger that is exactly len bytes long.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RSACore

        private RSACore()
    • Method Detail

      • getByteLength

        static int getByteLength​(java.math.BigInteger b)
        Return the number of bytes required to store the magnitude byte[] of this BigInteger. Do not count a 0x00 byte toByteArray() would prefix for 2's complement form.
      • getByteLength

        static int getByteLength​(java.security.interfaces.RSAKey key)
        Devuelve el número de octetos necesarios para almacenar el módulo de una clave RSA.
        Parameters:
        key - Clave RSA.
        Returns:
        Número de octetos necesarios para almacenar el módulo de la clave proporcionada.
      • convert

        static byte[] convert​(byte[] b,
                              int ofs,
                              int len)
      • rsa

        static byte[] rsa​(byte[] msg,
                          java.security.interfaces.RSAPublicKey key)
                   throws javax.crypto.BadPaddingException
        Ejecuta un cifrado RSA con una clave pública.
        Throws:
        javax.crypto.BadPaddingException
      • crypt

        private static byte[] crypt​(byte[] msg,
                                    java.math.BigInteger n,
                                    java.math.BigInteger exp)
                             throws javax.crypto.BadPaddingException
        Operación general de cifrado RSA (un modPow()).
        Throws:
        javax.crypto.BadPaddingException
      • priCrypt

        private static byte[] priCrypt​(byte[] msg,
                                       java.math.BigInteger n,
                                       java.math.BigInteger exp)
                                throws javax.crypto.BadPaddingException
        RSA non-CRT private key operations.
        Throws:
        javax.crypto.BadPaddingException
      • parseMsg

        private static java.math.BigInteger parseMsg​(byte[] msg,
                                                     java.math.BigInteger n)
                                              throws javax.crypto.BadPaddingException
        Parse the msg into a BigInteger and check against the modulus n.
        Throws:
        javax.crypto.BadPaddingException
      • toByteArray

        private static byte[] toByteArray​(java.math.BigInteger bi,
                                          int len)
        Return the encoding of this BigInteger that is exactly len bytes long. Prefix/strip off leading 0x00 bytes if necessary. Precondition: bi must fit into len bytes.
      • getBlindingRandomPair

        private static RSACore.BlindingRandomPair getBlindingRandomPair​(java.math.BigInteger e,
                                                                        java.math.BigInteger d,
                                                                        java.math.BigInteger n)