Tuesday, January 10, 2012

Encrypting SMS in Android تشفير الرسائل القصيرة بنظام الأندرويد

Hello dear readers, after what seems like a century, I finally update again! This time in two languages at the same time. After learning that some people actually read the blog and want to see more updates, I decided to touch on a sensitive subject nowadays, especially with all the chaos that's roaming the Middle East region now. This subject is the encryption of SMS in mobile phones (currently for Android).

مرحباً بالقراء الأعزاء. بعد غياب طويل مر على هذه المدونة سأقوم باذن الله بتحديثها أخيراً! هذه المرة سأكتب بلغتين بوقت واحد بدلاً من أن أفصل الشرح بمقالين مختلفين. بعد أن سمعت بعض التعليقات الطيبة على المقالات التقنية بهذه المدونة قررت أن أكتب عن موضوع حساس خصوصاً في أيام الفوضى بمنطقة الشرق الأوسط، ألا و هو تشفير الرسائل القصيرة بالهواتف (الأندرويد حالياً).

There is a number of Android apps that can be used to encrypt SMS messages, however in this article I'm going to focus on the one I tested, which is TextSecure. TextSecure is an open source app that allows the user to encrypt his SMS messages both locally in his device and while they are in transmit, to ensure protection & privacy at all times for his secured SMS messages.

يوجد عدد من برامج الاندرويد التي تمكنك من تشفير الرسائل القصيرة و لكني هنا سأركز على برنامج TextSecure حيث انه مفتوح المصدر و يمكنك من تشفير الرسائل القصيرة محلياً داخل الجهاز و أيضاً عند إرسالها بالشبكة حتى تكون بأمن طوال الوقت .

You can download TextSecure for your Android phone here (still in beta) and play with it. I will assume you have already downloaded it with no problems. When you run it for the first time, you will see this window:

يمكنك تحميله مجاناً من هنا (لا يزال بنسخة تجريبية) و اللعب به. سأقوم بالشرح الان على افتراض انك قمت بتحميله و تثبيته بجهازك. عندما تقوم بتشغيله أول مرة ستجد هذه الشاشة: 



Click Accept, then Click I understand on the next window as well. You will now come to a screen asking you to enter a passphrase. A screen like this:

اضغط على Accept  ثم اضغط على I understand  بالشاشة التالية. ستصل الان إلى شاشة تطلب منك إدخال عبارة سرية:



What does it mean by a passphrase? The answer is simple: It is like a password, but can be much longer. Instead of a weak, easy to guess password like ILoveYou123, or a difficult one to remember like Gsu72^&1Kj, you can use a passphrase that is both difficult to guess and also easy to remember, for example: I love to go to School and eat my Favorite Twix Bar!

The advantage is obvious: It is very difficult to guess by a human, it would take forever for a machine to guess, and it is very easy to remember. It's also a lot more fun! No longer should you have to write angry passwords and whack the keyboard because you could barely remember the complex password you had to use.


ما المقصود بعبارة سرية و ما الفرق بينها و بين كلمة السر؟ الاجابة بسيطة: العبارة السرية تشابه كلمة السر إلا أنها أطول بكثير و تتكون من كلمات مفهومة لديك. بدلاً من استخدام كلمة سر قصيرة و سهلة للتخمين مثل ILoveYou123 أو استخدام كلمة سر يصعب عليك تذكرها مثل Gsu72^&1Kj يمكنك استخدام عبارة سرية بحيث يصعب تخمينها آلياً باستخدام برامج الاختراق و كذلك يكون تذكرها أمراً سهلاً عليك، مثلاً العبارة السرية: I love to go to School and eat my Favorite Twix Bar!

الفائدة من استخدام عبارة سرية بدلاً من كلمة سرية واضح جداً: العبارة السرية يصعب تخمينها سواء من قبل انسان آخر أو برنامج، و لكن تذكرها سهل عليك و يمكنك أن تطيل كلماتها دون التأثير على سهولة تذكرها، كما أنها أكثر متعة بالاستخدام! لا داعي لاستخدام كلمات سر معقدة تجعلك تصب جام غضبك على الكيبورد بمحاولة تذكر حروفها المعقدة.

So now I guess you thought of a very nice passphrase that is easy to remember and more fun to write? Great, enter it in the field and click Ok. Next, TextSecure will ask you to make an encrypted copy of your SMS messages. Click Copy.

حسناً لنتفرض انك فكرت بعبارة سرية طويلة و سهلة التذكر، الان كل ما عليك هو ادخالها مرتين ثم الضغط على Ok. سيطلب منك TextSecure الاذن بالقيام بنسخة مشفرة من رسائلك الخاصة. قم بالضغط على Copy.



Now we can see the main menu of TextSecure, with the Settings menu expanded. Let's study each section in the image.

الان قمنا بالدخول للشاشة الرئيسية لبرنامج TextSecure، و قمنا بتفعيل قائمة الخيارات Settings، لنقم بمعاينة الاختيارات المتاحة بالقائمة.



1- New Message: Click here to create a new normal message. The messages will be encrypted only when a Secure Session is started. One a Secure Session is started, the messages will be encrypted when locally stored and when going in transit to the recipient.The recipient must be using TextSecure.

1- رسالة جديدة: اضغط هنا لكتابة رسالة جديدة عادية (غير مشفرة). ستكون الرسائل مشفرة فقط عند البدء بقناة مشفرة Secure Session. عند البدء بقناة مشفرة ستكون الرسائل مشفرة داخل جهازك فقط، اذا أردت أن يتم تشفيرها أثناء الارسال بالشبكة يجب على صديقك المستقبل للرسالة أن يقوم باستخدام TextSecure أيضاً حتى يمكن القيام بتشفير الرسائل القصيرة أثناء الارسال.

2- Messages List: This is the area where you can browse your messages. If the passphrase is not entered, all the messages will be encrypted and impossible to read.

2- قائمة الرسائل: هنا تجد الرسائل القديمة. اذا لم تقم بادخال عبارتك السرية بالبرنامج فستظهر الرسائل مشفرة و لا يمكن قرائتها.

3- Batch Mode: Used when more than one conversation is used. We don't need this now.

3- وضع الدفعات: يستخدم للتحكم بأكثر من محادثة بوقت واحد، لا يهمنا هذا الاختيار الان.

4- Secure Session: This is the fun part! Here we can instantly stat a secure session with a friend who must have installed TextSecure too.

4- قناة التشفير: هنا يبدأ المرح الحقيقي! يمكنك هنا أن تبدأ قناة  تشفير مع أي صديق لك مباشرة على شرط أن يقوم هو أيضاً باستخدام TextSecure.

5- Search: To search through your messages.

5- البحث: للبحث برسائلك الخاصة.

6- Settings: Lots of different settings for the application. We will explain all settings in some detail soon. (Don't run!)

 6- الاعدادات: توجد اعدادات كثيرة بالبرنامج، سنقوم بشرح أهمها لاحقاً (خلك معانا!).

7- Import/Export: To import messages from or to the SD Card.

7- استيراد و تصدير: لاستيراد أو تصدير الرسائل من و إلى كرت الSD.

8- More (Clear Passphrase): Clicking More will show the Clear Passphrase option. This option removes the cached passphrase (which you entered before, remember?) and is similar in effect to signing out. The messages will appear encrypted again and you have to enter your passphrase to see them again or send an encrypted SMS.

8- المزيد (مسح العبارة السرية): اذا قمت بمسح العبارة السرية فكأنك قمت بتسجيل الخروج و بالتالي لن تكون الرسائل قابلة للقراءة و لن يمكنك ارسال رسائل مشفرة حتى تقوم بادخال العبارة السرية الصحيحة.

Let's start with option 8 (More - Clear Passphrase). If I click it, I will need to enter the passphrase again to be able to decrypt the messages or send encrypted ones, as shown here in the figure:

لنبدأ بالاختيار 8 و هو مسح العبارة السرية. اذا ضغطنا عليه سيقوم البرنامج بطلب ادخال العبارة السرية من جديد (نفس العبارة القديمة و ليست عبارة جديدة، كأنه يطلب تسجيل الدخول). اذا أدخلتها صحيحة ستصبح الرسائل قابلة للقراءة مرة أخرى.


You have to enter your passphrase correctly to see the messages. Now that we have entered our passphrase, let us try to send a normal SMS first. We can then start a Secure Session to encrypt the messages. The recipient must be using TextSecure too. Click on New Message.This screen will appear to you:

الان و بعد أن ادخلنا العبارة السرية الصحيحة يمكننا قراءة الرسائل المشفرة. لنقم الان بإرسال رسالة عادية غير مشفرة ثم سنقوم بفتح قناة مشفرة Secure Session لتشفير الرسائل اثناء ارسالها بالشبكة. يجب على المستقبل أن يستخدم TextSecure لنحصل على هذه الميزة. قم بالضغط على New Message  الان.


Simply choose a name from your contacts to send an SMS from. Without the recipient having TextSecure, your SMS will not be encrypted while in transit; it will only be encrypted in your device (with your passphrase, remember?). If you wish to encrypt your message in transit (while they are being sent) your friend must also use TextSecure so that you can start a Secure Session with them.

اختر اسم احد جهات الاتصال لديك. اذا لم يكونوا يستخدمون TextSecure فكل ما ستحصل عليه هو تشفير الرسائل القصيرة داخل جهازك لكنها لن تكون مشفرة اثناء ارسالها بالهواء. للحصول على التشفير الكامل اثناء الاتصال يجب عليك فتح قناة تشفير مع شخص يستخدم TextSecure.

Now type a friend's name and click. You will come to a screen like this, this is the normal unencrypted conversation window. You can tell the messages are not encrypted because there are no lock icons anywhere. You will see later how lock icons appear if the messages are encrypted. I am now starting an unencrypted SMS conversation with my friend Saleh.

قم بادخال اسم و اضغط. ستصل إلى شاشة كالتالية، و هي شاشة الرسالة العادية غير المشفرة. يمكنك معرفة ذلك عن طريق فقدان أيقونة القفل التي يفترض أن تكون موجودة بالبرنامج اذا كانت هناك قناة تشفير فعالة. سنقوم الان بإرسال رسالة غير مشفرة إلى صديقنا صالح.



Now what if we wanted to start a Secure Session? Simply click on Menu(the ... button to the lower right, or your Android device menu button) to see the next screen. Click on Start Secure Session.

إذا أردت البدء بقناة تشفير فما عليك هو الضغط على مفتاح القائمة ثم الضغط على Start Secure Session.


You will see a question to confirm the start of the secure session, click Yes. A key exchange message will be sent to Saleh, whose device will receive it and process it. Now we are running an encrypted SMS conversation. Every SMS I send to Saleh or receive from him through TextSecure will be encrypted in transit and locally on our devices. That is all!

سيسألك البرنامج عن تأكيد بدء قناة التشفير و قم بالموافقة. سيقوم البرنامج بنفسه بإرسال رسالة لتبادل مفاتيح التشفير السرية. نحن الان نقوم بارسال و استقبال رسائل قصيرة مشفرة من و إلى صديقنا صالح. ستكون هذه الرسائل مشفرة اثناء عبورها الشبكة و أيضاً داخل أجهزتنا.

However, what if you wanted to verify that you are actually talking to Saleh and not someone trying to be him? Click on Menu again and choose Secure Session Options, as shown here:

و لكن ما إذا ساورني الشك بأن هناك من ينتحل شخصية صالح؟ اضغط على زر القائمة و اختر Secure Session Options كما هو موضح تحت:


When you click on it, you will see three options: Verify Session, Verify Identity, and Abort Secure Session. Abort Secure Session is used to terminate the encrypted SMS conversation and return to normal unencrypted mode.

سترى ثلاث اختيارات Verify Session, Verify Identity, Abort Secure Session. 
اختيار Abort Secure Session  يقوم بكل بساطة بانهاء القناة المشفرة و العودة إلى الوضع العادي الغير مشفر.

Verify Identity is used to verify the 'fingerprints' of the keys used to identify you to your friend and vice versa. If you want to verify, it is recommended to use another channel of communication. For example send an email or use an encrypted chat client (like Line or Gibberbot) to verify the keys are the same on your device as well as your device.

اختيار Verify Identity يعينك على التأكد من هوية صديقنا صالح. سيعرض لك البرنامج "بصمة" خاصة بمفتاحك و مفتاح صديقك، و كل ما عليك فعله هو استخدام طريقة اتصال اخرى (مثل الايميل أو برنامج محادثة مشفر مثل Line  أو Gibberbot) للتأكد من تطابق بصمات المفاتيح عندكما. بهذه الطريقة نكون تأكدنا من أننا حقاً نقوم بالتحدث بسرية مع صالح.

The verify Session option is used to verify that this particular encrypted channel you two are using to encrypt SMS is secure, because SMS messages are encrypted with temporary session keys, not your identity key (for increased security!). So it would be better to verify the session keys using another channel of communication. If you can verify both the Identity key and the Session key, you can be sure that you are running a very secure encrypted communication. Make sure your friend sees the same number as you do. (Asking about the first 6 or last 6 letters is just enough, usually)

اختيار Verify Session  اختيار اضافي للتأكد من أن قناة التشفير نفسها لا يوجد فيها إلا أنا و صديقي صالح، و ذلك لأن الرسائل المرسلة بالشبكة تكون مشفرة بمفتاح مؤقت و ذلك للحصول على أمان إضافي و تصعيب كسر التشفير على من أراد التجسس. تأكد من أنك و صديقك تستخدمان نفس المفاتيح كما فعلنا عندما تحققنا من هوياتنا بالأعلى.




Now that we have verified the Identity and Session keys, we can safely start sending encrypted SMS! Notice how our names have lock icons next to them, it means the messages are encrypted. The lock icon on the top means our identities have been verified. We are set!

الان و قد قمنا بالتحقق من هوياتنا و سرية مفاتيحنا المؤقتة، يمكننا التأكد مئة بالمئة من سلامة قناة التشفير بيننا! لاحظ أيقونة القفل التي تظهر على الرسائل؟ انها تعني ان الرسائل مشفرة اثناء ارسالها بالشبكة. القفل الموجود بالأعلى يدل على أننا تأكدنا من هويات بعضنا. نحن جاهزون للتواصل المشفر!


Now that we have finished encrypting SMS messages and verifying the security and validity of encryption, let us see the options in TextSecure. Let us see the settings in TextSecure:

الان بعد أن قمنا باكمال تشفير الرسائل و تأكدنا من صحة التشفير و هويات الطرفين، لنرى بعضاً من الاعدادات الكثيرة التي يقدمها TextSecure. 






The 'Use for all SMS' choice allows you to let TextSecure absorb all SMS messages, so that they can be encrypted in its local database. If you don't choose this option, only the encrypted SMS messages will be stored by TextSecure, the others will be handled by the normal SMS app.

الاختيار Use for all SMS يمكنك من جعل TextSecure  يسحب كل الرسائل القصيرة لتخزينها بقاعدة بياناته المشفرة بجهازك. اذا لم تقم بهذا الاختيار فإن الرسائل الغير مشفرة ستوضع ببرنامج الرسائل القصيرة الأصلي Messaging و سيقوم TextSecure بالتعامل مع الرسائل المشفرة فقط.

In my opinion you should choose both the 'Dark Thread List Theme' and the 'Dark Conversation Theme' so that all text shows clearly in dark backgrounds, but this is up to your choice of course.

برأي الشخصي يفضل أن تقوم باختيار الخيارات Dark Thread List Theme  و Dark Conversation Theme  حتى تكون الخطوط واضحة مع الخلفيات القاتمة. قبل أن أقوم بهذا الاختيار لم اتمكن من قراءة النص لأن لونه كان أسود فوق خلفية سوداء.

This concludes my brief tutorial to using TextSecure on Android for local and in-transit encryption of SMS messages! Please take care of your privacy and throw your most-welcome questions here in the comments or at me in Twitter @Voulnet

نكون الان قد وصلنا إلى نهاية هذا الشرح الموجز لاستخدام برنامج TextSecure  لتشفير الرسائل القصيرة بالجهاز و أثناء الارسال بالشبكة! نرجو أن تكون النقاط واضحة, و نتمنى من القراء الأعزاء الاهتمام الشديد بخصوصيتهم على الانترنت!

بالطبع نرحب بكل الأسئل و التعليقات هنا في المدونة أو في حسابي بتويتر
@Voulnet

No comments:

Post a Comment