There is a maximum size of data to encrypt using RSA?

Werner Koch wk at gnupg.org
Thu Aug 2 20:05:41 CEST 2012


On Thu,  2 Aug 2012 16:11, contato at tiago.eti.br said:

> I am trying to encrypt a block of 1249 bytes with RSA, but when I use
> /gcry_sexp_build/ to build a s-expression to be encrypted the function
> return an empty s-expression.

You can't do this unless you have a huge key (e.g. 16k bit).  I suggest
to read a text book on practical implementation of public key
cryptography.  For example

@Book{Fer:03:PC,
  author =      "Niels Ferguson and Bruce Schneier",
  title =       "Practical Cryptography",
  language =    "USenglish",
  edition =     "first",
  publisher =   pub-WIL,
  address =     pub-WIL:adr,
  pages =       "xx + 410",
  year =        "2003",
  ISBN =        "0-471-22357-3",
  URL =         "http://www.macfergus.com/pc/"
}

there should also be similar courses available online.  The old Schneier
book 

@Book{Sch:96:AC,
  author =      "Bruce Schneier",
  title =       "Applied Cryptography",
  language =    "USenglish",
  edition =     "second",
  publisher =   pub-WIL,
  address =     pub-WIL:adr,
  pages =       "xxiii + 758",
  year =        "1996",
  ISBN =        "0-471-11709-9",
}

gives a good overview and a still good reference is the online available
HAC:

@Book{Men:96:HAC,
  author =      "Alfred J. Menezes and Paul van Oorschot and
                 Scott Vanstone",
  title =       "Handbook of Applied Cryptography",
  language =    "USenglish",
  publisher =   pub-CRC,
  address =     pub-CRC:adr,
  pages =       "xxvii + 780",
  year =        "1996",
  ISBN =        "0-8493-8523-7",
  keywords =    "cryptograpy",
}

And while I am at it:  Everyone in our business should have read this
book:

  http://www.cl.cam.ac.uk/~rja14/book.html

> Am I doing something wrong? Or Libgcrypt can not manipulate this amount
> of data.

It is one of the basic PKCS#1 checks it does.  However, in general
Libgcrypt does not protect you from doing entirely wrong stuff.


Salam-Shalom,

   Werner

-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.




More information about the Gcrypt-devel mailing list