Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: proto/xmpp/uim-protocols-xmpp-client.adb
- ===================================================================
- --- proto/xmpp/uim-protocols-xmpp-client.adb (revision 388)
- +++ proto/xmpp/uim-protocols-xmpp-client.adb (working copy)
- @@ -61,6 +61,8 @@
- with Network.Utils;
- +with GNUTLS.SASL;
- +
- package body UIM.Protocols.XMPP.Client is
- use Ada.Strings.Unbounded;
- @@ -74,10 +76,11 @@
- use Sax.Readers;
- use Unicode.CES;
- use Unicode.CES.Utf8;
- - use Ada.Strings.Unbounded;
- use Ada.Exceptions;
- + use GNUTLS.SASL;
- +
- use type Ada.Streams.Stream_Element_Offset;
- XML_String : Ada.Strings.Unbounded.Unbounded_String;
- @@ -89,21 +92,6 @@
- Host : String := "localhost";
- Password : String := "123";
- - function Hex_To_Oct (Sum : String) return String is
- - Result : String (Sum'First .. Sum'Last / 2);
- - J : Integer := Sum'First;
- -
- - begin
- - for Idx in Result'Range loop
- - Result (Idx)
- - := Character'Val (Integer'Value (("16#" & Sum (J .. J + 1) & "#")));
- -
- - J := J + 2;
- - end loop;
- -
- - return Result;
- - end Hex_To_Oct;
- -
- --------------
- -- Create --
- --------------
- @@ -471,68 +459,6 @@
- end Parse_Challenge;
- -
- - function Generate_SASL_String (JID_Par : String;
- - Pass_Par : String;
- - Host_Par : String;
- - Nonce_Par : String) -- Generates SASL string
- - return String
- - is
- - CNonce : String := "1a2f0ee81279451956625d2368";
- -
- - SY : String := Hex_To_Oct (GNAT.MD5.Digest (JID_Par &
- - ":" &
- - Host_Par &
- - ":" &
- - Pass_Par));
- -
- - HA1 : String := GNAT.MD5.Digest (SY & ":"
- - & Nonce_Par
- - & ":" & CNonce);
- - HA2 : String := GNAT.MD5.Digest ("AUTHENTICATE:xmpp/" & Host_Par);
- - Z : String := GNAT.MD5.Digest (HA1 & ":"
- - & Nonce_Par
- - & ":00000001:"
- - & CNonce & ":auth:"
- - & HA2);
- -
- - Realm_Reply : String
- - := "username="""
- - & JID_Par
- - & """,realm=""" & Host_Par
- - & """,nonce=""" & Nonce_Par
- - & """,cnonce=""" & CNonce
- - & """,nc=00000001"
- - & ",qop=auth,digest-uri=""xmpp/"
- - & Host_Par
- - & """,response=" & Z
- - & ",charset=utf-8";
- -
- - X : Integer := 4 * (Realm_Reply'Length + 2) / 3;
- - Y : Integer := X + 2 * (X / 76);
- -
- - Realm_Reply_Base_64 : String (Realm_Reply'First .. Y);
- - Len : Natural;
- -
- - begin
- - Ada.Text_IO.Put_Line ("SY = " & SY);
- - Ada.Text_IO.Put_Line ("HA1 = " & HA1);
- - Ada.Text_IO.Put_Line ("HA2 = " & HA2);
- - Ada.Text_IO.Put_Line ("Z = " & Z);
- - Ada.Text_IO.Put_Line ("Realm_Reply = " & Realm_Reply);
- - Utils.Base64.Encode
- - (Network.Utils.To_Stream_Element_Array (Realm_Reply),
- - Realm_Reply_Base_64,
- - Len);
- - Ada.Text_IO.Put_Line ("Realm_Reply_Base_64 = " & Realm_Reply_Base_64);
- -
- - return
- - "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"
- - & Realm_Reply_Base_64 (Realm_Reply_Base_64'First .. Len)
- - & "</response>";
- -
- - end Generate_SASL_String;
- -
- -----------------------------
- -- Parse_Stream_Features --
- -----------------------------
- Index: agnutls/gnutls-sasl.adb
- ===================================================================
- --- agnutls/gnutls-sasl.adb (revision 0)
- +++ agnutls/gnutls-sasl.adb (revision 0)
- @@ -0,0 +1,140 @@
- +------------------------------------------------------------------------------
- +-- --
- +-- Unix Instant Messenger --
- +-- --
- +------------------------------------------------------------------------------
- +-- --
- +-- Copyright © 2009 Ada Labs <coopht@gmail.com> --
- +-- --
- +-- This is free software; you can redistribute it and/or modify it under --
- +-- terms of the GNU General Public License as published by the Free Soft- --
- +-- ware Foundation; either version 2, or (at your option) any later ver- --
- +-- sion. UIM is distributed in the hope that it will be useful, but WITH- --
- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
- +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
- +-- for more details. You should have received a copy of the GNU General --
- +-- Public License distributed with UIM; see file COPYING. If not, write --
- +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
- +-- Boston, MA 02110-1301, USA. --
- +-- --
- +-- As a special exception, if other files instantiate generics from this --
- +-- unit, or you link this unit with other files to produce an executable, --
- +-- this unit does not by itself cause the resulting executable to be --
- +-- covered by the GNU General Public License. This exception does not --
- +-- however invalidate any other reasons why the executable file might be --
- +-- covered by the GNU Public License. --
- +-- --
- +------------------------------------------------------------------------------
- +--
- +-- <Unit> GNUTLS.SASL
- +-- <ImplementationNotes>
- +--
- +------------------------------------------------------------------------------
- +-- $Revision: 386 $ $Author: grubnikov $
- +-- $Date: 2010-08-01 01:26:03 +0400 (Вск, 01 Авг 2010) $
- +------------------------------------------------------------------------------
- +with Ada.Exceptions;
- +with Ada.Streams;
- +with Ada.Strings.Unbounded;
- +with Ada.Text_IO;
- +
- +with GNAT.MD5;
- +with GNAT.Sockets;
- +
- +with UIM.Utils.Base64;
- +
- +with Network.Utils;
- +
- +package body GNUTLS.SASL is
- +
- + use Ada.Strings.Unbounded;
- + use Ada.Text_IO;
- + use Ada.Strings.Unbounded;
- +
- + use Ada.Exceptions;
- +
- + use type Ada.Streams.Stream_Element_Offset;
- +
- + ------------------
- + -- Hex_To_Oct --
- + ------------------
- + function Hex_To_Oct (Sum : String) return String is
- + Result : String (Sum'First .. Sum'Last / 2);
- + J : Integer := Sum'First;
- +
- + begin
- + for Idx in Result'Range loop
- + Result (Idx)
- + := Character'Val (Integer'Value (("16#" & Sum (J .. J + 1) & "#")));
- +
- + J := J + 2;
- + end loop;
- +
- + return Result;
- + end Hex_To_Oct;
- +
- + -----------------------------
- + -- Generate_SASL_String --
- + -----------------------------
- + function Generate_SASL_String (JID_Par : String;
- + Pass_Par : String;
- + Host_Par : String;
- + Nonce_Par : String) -- Generates SASL string
- + return String
- + is
- + CNonce : String := "1a2f0ee81279451956625d2368";
- +
- + SY : String := Hex_To_Oct (GNAT.MD5.Digest (JID_Par &
- + ":" &
- + Host_Par &
- + ":" &
- + Pass_Par));
- +
- + HA1 : String := GNAT.MD5.Digest (SY & ":"
- + & Nonce_Par
- + & ":" & CNonce);
- + HA2 : String := GNAT.MD5.Digest ("AUTHENTICATE:xmpp/" & Host_Par);
- + Z : String := GNAT.MD5.Digest (HA1 & ":"
- + & Nonce_Par
- + & ":00000001:"
- + & CNonce & ":auth:"
- + & HA2);
- +
- + Realm_Reply : String
- + := "username="""
- + & JID_Par
- + & """,realm=""" & Host_Par
- + & """,nonce=""" & Nonce_Par
- + & """,cnonce=""" & CNonce
- + & """,nc=00000001"
- + & ",qop=auth,digest-uri=""xmpp/"
- + & Host_Par
- + & """,response=" & Z
- + & ",charset=utf-8";
- +
- + X : Integer := 4 * (Realm_Reply'Length + 2) / 3;
- + Y : Integer := X + 2 * (X / 76);
- +
- + Realm_Reply_Base_64 : String (Realm_Reply'First .. Y);
- + Len : Natural;
- +
- + begin
- + Ada.Text_IO.Put_Line ("SY = " & SY);
- + Ada.Text_IO.Put_Line ("HA1 = " & HA1);
- + Ada.Text_IO.Put_Line ("HA2 = " & HA2);
- + Ada.Text_IO.Put_Line ("Z = " & Z);
- + Ada.Text_IO.Put_Line ("Realm_Reply = " & Realm_Reply);
- + Utils.Base64.Encode
- + (Network.Utils.To_Stream_Element_Array (Realm_Reply),
- + Realm_Reply_Base_64,
- + Len);
- + Ada.Text_IO.Put_Line ("Realm_Reply_Base_64 = " & Realm_Reply_Base_64);
- +
- + return
- + "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>"
- + & Realm_Reply_Base_64 (Realm_Reply_Base_64'First .. Len)
- + & "</response>";
- +
- + end Generate_SASL_String;
- +
- +end GNUTLS.SASL;
- Index: agnutls/gnutls-sasl.ads
- ===================================================================
- --- agnutls/gnutls-sasl.ads (revision 0)
- +++ agnutls/gnutls-sasl.ads (revision 0)
- @@ -0,0 +1,52 @@
- +------------------------------------------------------------------------------
- +-- --
- +-- Unix Instant Messenger --
- +-- --
- +------------------------------------------------------------------------------
- +-- --
- +-- Copyright © 2009 Ada Labs <coopht@gmail.com> --
- +-- --
- +-- This is free software; you can redistribute it and/or modify it under --
- +-- terms of the GNU General Public License as published by the Free Soft- --
- +-- ware Foundation; either version 2, or (at your option) any later ver- --
- +-- sion. UIM is distributed in the hope that it will be useful, but WITH- --
- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
- +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
- +-- for more details. You should have received a copy of the GNU General --
- +-- Public License distributed with UIM; see file COPYING. If not, write --
- +-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
- +-- Boston, MA 02110-1301, USA. --
- +-- --
- +-- As a special exception, if other files instantiate generics from this --
- +-- unit, or you link this unit with other files to produce an executable, --
- +-- this unit does not by itself cause the resulting executable to be --
- +-- covered by the GNU General Public License. This exception does not --
- +-- however invalidate any other reasons why the executable file might be --
- +-- covered by the GNU Public License. --
- +-- --
- +------------------------------------------------------------------------------
- +--
- +-- <Unit> UIM.Protocols.XMPP.Client
- +-- <ImplementationNotes>
- +--
- +------------------------------------------------------------------------------
- +-- $Revision: 381 $ $Author: coopht $
- +-- $Date: 2010-07-18 21:36:24 +0400 (Вск, 18 Июл 2010) $
- +------------------------------------------------------------------------------
- +with Network;
- +
- +package GNUTLS.SASL is
- +
- + ----------------------------
- + -- Generate_SASL_String --
- + ----------------------------
- + function Generate_SASL_String (JID_Par : String;
- + Pass_Par : String;
- + Host_Par : String;
- + Nonce_Par : String) return String;
- +
- + function Hex_To_Oct (Sum : String) return String;
- +
- +private
- +
- +end GNUTLS.SASL;
- Index: agnutls/agnutls.gpr
- ===================================================================
- --- agnutls/agnutls.gpr (revision 387)
- +++ agnutls/agnutls.gpr (working copy)
- @@ -33,6 +33,8 @@
- -- $Revision$ $Author$
- -- $Date$
- ------------------------------------------------------------------------------
- +with "../core/network/network";
- +with "../utils/utils";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement