Re: Encrypting long text

2021-12-16 Thread Monte Goulding via use-livecode
I have opened this issue to correct the documentation. Autocomplete parses the 
syntax definitions in the docs to create a list of possible command variations.
https://quality.livecode.com/show_bug.cgi?id=23489

> On 17 Dec 2021, at 6:08 am, Sean Cole via use-livecode 
>  wrote:
> 
> Hi Mark
> 
> So it must be the auto-completes that have the wrong possible values added
> to its list. Type 'encrypt' into the script editor and go to the bottom,
> then right and there are every possible iteration based on the syntax given
> in the dictionary. This does not match up with your description so perhaps
> needs looking in to.
> 
> Thanks for your help
> 
> Sean
> 
> On Thu, 16 Dec 2021 at 17:36, Mark Waddingham via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> 
>> On 2021-12-16 17:09, Sean Cole via use-livecode wrote:
>>> Thanks Mark,
>>> 
>>> New problem. Trying to use aes-256-ctr instead. I'm following the
>>> syntax in
>>> the dictionary but it throws a red cross on it:
>>> 
>>> encrypt tData using "aes-256-ctr" with key tMyKey and salt tMySalt
>> 
>> I think you can either specify a key, or a password with an optional
>> salt.
>> 
>> If you specify a password it uses the provided salt (or a random one if
>> one is not provided) to generate a key of the correct length (the bit
>> length of the cipher).
>> 
>> If you provide a key then it uses that verbatim to encrypt the data (in
>> this case the key must be the correct number of bits as defined by the
>> chosen cipher - 256 in this case).
>> 
>> Warmest Regards,
>> 
>> Mark.
>> 
>> --
>> Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
>> LiveCode: Everyone can create apps
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encrypting long text

2021-12-16 Thread Sean Cole via use-livecode
Hi Mark

So it must be the auto-completes that have the wrong possible values added
to its list. Type 'encrypt' into the script editor and go to the bottom,
then right and there are every possible iteration based on the syntax given
in the dictionary. This does not match up with your description so perhaps
needs looking in to.

Thanks for your help

Sean

On Thu, 16 Dec 2021 at 17:36, Mark Waddingham via use-livecode <
use-livecode@lists.runrev.com> wrote:

> On 2021-12-16 17:09, Sean Cole via use-livecode wrote:
> > Thanks Mark,
> >
> > New problem. Trying to use aes-256-ctr instead. I'm following the
> > syntax in
> > the dictionary but it throws a red cross on it:
> >
> > encrypt tData using "aes-256-ctr" with key tMyKey and salt tMySalt
>
> I think you can either specify a key, or a password with an optional
> salt.
>
> If you specify a password it uses the provided salt (or a random one if
> one is not provided) to generate a key of the correct length (the bit
> length of the cipher).
>
> If you provide a key then it uses that verbatim to encrypt the data (in
> this case the key must be the correct number of bits as defined by the
> chosen cipher - 256 in this case).
>
> Warmest Regards,
>
> Mark.
>
> --
> Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encrypting long text

2021-12-16 Thread Mark Waddingham via use-livecode

On 2021-12-16 17:09, Sean Cole via use-livecode wrote:

Thanks Mark,

New problem. Trying to use aes-256-ctr instead. I'm following the 
syntax in

the dictionary but it throws a red cross on it:

encrypt tData using "aes-256-ctr" with key tMyKey and salt tMySalt


I think you can either specify a key, or a password with an optional 
salt.


If you specify a password it uses the provided salt (or a random one if 
one is not provided) to generate a key of the correct length (the bit 
length of the cipher).


If you provide a key then it uses that verbatim to encrypt the data (in 
this case the key must be the correct number of bits as defined by the 
chosen cipher - 256 in this case).


Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encrypting long text

2021-12-16 Thread Sean Cole via use-livecode
Thanks Mark,

New problem. Trying to use aes-256-ctr instead. I'm following the syntax in
the dictionary but it throws a red cross on it:

encrypt tData using "aes-256-ctr" with key tMyKey and salt tMySalt


What is wrong with this syntax that the auto language detector shows it as
a mistake?
Sean

On Thu, 16 Dec 2021 at 16:45, Mark Waddingham via use-livecode <
use-livecode@lists.runrev.com> wrote:

> On 2021-12-16 16:23, Sean Cole via use-livecode wrote:
> > Hi all,
> > I'm trying to use RSA to encrypt data from a text field like an address
> > or
> > notes. When I try to use the encrypt command I get a result 'message
> > too
> > long'. What is the method for encrypting long or large data?
> >
> > My current line of code:
> >encrypt tData using rsa with public key tMyKey and
> > passphrase tMyPass
>
> RSA encryption can only encrypt data up to a certain length (I can't
> remember off the top of my head the exact relation, but it is related to
> the size of the key) so it isn't designed to be used on arbitrary length
> messages.
>
> Encrypting arbitrary length messages is the domain of symmetric
> encryption functions - like AES and friends.
>
> The solution, therefore, is to combine the two:
>
>1) Generate a random (using randomBytes()) fixed length encryption key
> FixedKey
>
>2) Encrypt the actual data using a symmetric algorithm with FixedKey
> as password
>
>2) Use RSA to encrypt the (fixed length!) key FixedKey
>
>4) Make you message the RSA-encrypted FixedKey followed by the
> encrypted data
>
> The RSA encrypted FixedKey will be a constant length, and thus you can
> just split that off of the combined data, decrypt it using RSA and then
> use the result to decrypt the payload.
>
> Hope this helps!
>
> Mark.
>
> --
> Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Encrypting long text

2021-12-16 Thread Mark Waddingham via use-livecode

On 2021-12-16 16:23, Sean Cole via use-livecode wrote:

Hi all,
I'm trying to use RSA to encrypt data from a text field like an address 
or
notes. When I try to use the encrypt command I get a result 'message 
too

long'. What is the method for encrypting long or large data?

My current line of code:
   encrypt tData using rsa with public key tMyKey and
passphrase tMyPass


RSA encryption can only encrypt data up to a certain length (I can't 
remember off the top of my head the exact relation, but it is related to 
the size of the key) so it isn't designed to be used on arbitrary length 
messages.


Encrypting arbitrary length messages is the domain of symmetric 
encryption functions - like AES and friends.


The solution, therefore, is to combine the two:

  1) Generate a random (using randomBytes()) fixed length encryption key 
FixedKey


  2) Encrypt the actual data using a symmetric algorithm with FixedKey 
as password


  2) Use RSA to encrypt the (fixed length!) key FixedKey

  4) Make you message the RSA-encrypted FixedKey followed by the 
encrypted data


The RSA encrypted FixedKey will be a constant length, and thus you can 
just split that off of the combined data, decrypt it using RSA and then 
use the result to decrypt the payload.


Hope this helps!

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Encrypting long text

2021-12-16 Thread Sean Cole via use-livecode
Hi all,
I'm trying to use RSA to encrypt data from a text field like an address or
notes. When I try to use the encrypt command I get a result 'message too
long'. What is the method for encrypting long or large data?

My current line of code:
   encrypt tData using rsa with public key tMyKey and
passphrase tMyPass

Thanks

Sean
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode