IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Sécurité Java Discussion :

Crypter et decrypter un fichier avec AES


Sujet :

Sécurité Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 47
    Points : 43
    Points
    43
    Par défaut Crypter et decrypter un fichier avec AES
    Bonjour,

    J'ai récupéré la classe AESEncryptor de ce forum (http://www.developpez.net/forums/sho...t=13730&page=2)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.io.OutputStream;
    import java.security.GeneralSecurityException;
    import java.security.InvalidKeyException;
    import java.security.Key;
    import java.security.NoSuchAlgorithmException;
    import java.security.SecureRandom;
    import javax.crypto.Cipher;
    import javax.crypto.KeyGenerator;
    import javax.crypto.SecretKey;
     
    /**
     *
     * @author Absil Romain
     */
    public class AESEncryptor
    {
        /**
         * Generates a secret key for AES encrypting and write it in a file.
         * @param outputFileNamethe file to write the generated key in.
         **/
        public static void generateKey(String outputFileName)
        {
           try
           {
                KeyGenerator keygen = KeyGenerator.getInstance("AES");
                SecureRandom random = new SecureRandom();
                keygen.init(random);
                SecretKey key = keygen.generateKey();
                ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(outputFileName));
                out.writeObject(key);
                out.close();
           }
           catch(Exception e)
           {
               e.printStackTrace();
           }
        }
     
        /**
         * Encryts or decryts (depends on mode) the file inputFileName, and save 
         * the result in the file outputFileName.
         * @param inputFileName the file to encryt or decrypt.
         * @param outputFileName the file to save the result of encryting or 
         * decrypting.
         * @param ode the mode : encryption (Cipher.ENCRYPT_MODE) or decryption 
         * (Cipher.DECRYPT_MODE).
         * @see javax.crypto.Cipher
         **/
        public static void encryptFile(String inputFileName, String outputFileName, String keyFileName, int mode) 
        {
            InputStream in = null;
            OutputStream out = null;
            try
            {
                ObjectInputStream keyIn = new ObjectInputStream(
                    new FileInputStream(keyFileName));
                Key key = (Key)keyIn.readObject();
                keyIn.close();
     
                in = new FileInputStream(inputFileName);
                out = new FileOutputStream(outputFileName);
                Cipher cipher = Cipher.getInstance("AES");
                cipher.init(mode, key);
     
                crypt(in, out, cipher);
                in.close();
                out.close();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
     
        private static void crypt(InputStream in, OutputStream out, Cipher cipher)
            throws IOException, GeneralSecurityException
        {
            int blockSize = cipher.getBlockSize();
            int outputSize = cipher.getOutputSize(blockSize);
            byte[] inBytes = new byte[blockSize];
            byte[] outBytes = new byte[outputSize];
     
            int inLength = 0;
            boolean done = false;
            while(!done)
            {
                inLength = in.read(inBytes);
                if(inLength == blockSize)
                {
                    int outLength = cipher.update(inBytes, 0, blockSize, outBytes);
                    out.write(outBytes, 0, outLength);
                }
                else
                    done = true;
            }
     
            if(inLength > 0)
                outBytes = cipher.doFinal(inBytes, 0, inLength);
            else
                outBytes = cipher.doFinal();
     
            out.write(outBytes);
        }
        public static void main(String[] args){
                AESEncryptor.generateKey("key/k.r2o");              
                   //AESEncryptor.encryptFile("test/ch10-crypto.pdf","test/newFileAES","key/k.r2o", Cipher.ENCRYPT_MODE);
                AESEncryptor.encryptFile("test/newFileAES", "test/ch10-cryptoN.pdf","key/k.r2o", Cipher.DECRYPT_MODE);
        }            
    }
    J'arrive à crypter mon fichier (enfin je suppose, puisque je ne peux pas le vérifier) avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    AESEncryptor.encryptFile("test/ch10-crypto.pdf","test/newFileAES","key/k.r2o", Cipher.ENCRYPT_MODE);
    mais en voulant décrypter avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    AESEncryptor.encryptFile("test/newFileAES", "test/ch10-cryptoN.pdf","key/k.r2o", Cipher.DECRYPT_MODE);
    j'ai l'exception suivante :
    javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA6275)
    at javax.crypto.Cipher.doFinal(DashoA12275)
    at AESEncryptor.crypt(AESEncryptor.java:107)
    at AESEncryptor.encryptFile(AESEncryptor.java:72)
    at AESEncryptor.main(AESEncryptor.java:114)
    J'utilise le jdk1.5.0_03.

    Merci de votre aide.

  2. #2
    Membre averti Avatar de Razgriz
    Profil pro
    Professeur / chercheur en informatique / mathématiques
    Inscrit en
    Avril 2006
    Messages
    391
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Professeur / chercheur en informatique / mathématiques

    Informations forums :
    Inscription : Avril 2006
    Messages : 391
    Points : 306
    Points
    306
    Par défaut
    Cette classe est une vielle version que j'ai écrite, en voici une plus récente :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
     
    package org.cosmopol.crypto;
     
    import java.io.EOFException;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.io.OutputStream;
    import java.security.InvalidKeyException;
    import java.security.NoSuchAlgorithmException;
    import java.security.NoSuchProviderException;
    import java.security.Provider;
    import java.security.SecureRandom;
    import javax.crypto.Cipher;
    import javax.crypto.KeyGenerator;
    import javax.crypto.SecretKey;
    import javax.crypto.NoSuchPaddingException;
    import javax.crypto.ShortBufferException;
    import javax.crypto.IllegalBlockSizeException;
    import javax.crypto.BadPaddingException;
     
    /**
     * This class provides methods to generate keys, crypt or decrypt stream and
     * files with a symetric-key algorithm such as the AES, DES and so on.
     * @author Absil Romain
     */
    public class SymetricEncryptor extends CipherEncryptor
    {
        private SecretKey key;
        private String algorithm;
     
        /**
         * The constant for the AES symetric-key algorithm.
         **/
        public static String AES = "AES";
     
        /**
         * The constant for the DES symetric-key algorithm.
         **/
        public static String DES = "DES";
     
        /**
         * The constant for the triple DES (DES-EDE) symetric-key algorithm.
         **/
        public static String DES_EDE = "DESede";
     
        /**
         * The constant for the Blowfish symetric-key algorithm.
         **/
        public static String BLOWFISH = "Blowfish";
     
        /**
         * The constant for the RC2 symetric-key algorithm.
         **/
        public static String RC2 = "RC2";
     
        /**
         * The constant for the Arcfour symetric-key algorithm.
         **/
        public static String ARCFOUR = "RC4";
     
        /**
         * Constructs a new symetric encryptor with the specified key.<br>
         * @param key the secret key to crypt or decrypt datas.
         **/
        public SymetricEncryptor(SecretKey key)
        {
            this.key = key;
            this.algorithm = key.getAlgorithm();
        }
     
        /**
         * Constructs a new symetric encryptor with the specified key file name 
         * containing the secret key.
         * @param keyFileName the name of the file containing the secret key.
         * @throws java.io.FileNotFoundException if the file containing the secret
         * key doesn't exist.
         * @throws java.io.IOException if an I/O error occurs during reading the
         * key.
         * @throws java.lang.ClassNotFoundException if the class of the key is
         * unknown.
         **/
        public SymetricEncryptor(String keyFileName)
            throws FileNotFoundException, IOException, ClassNotFoundException
        {
            ObjectInputStream in = new ObjectInputStream(new FileInputStream(keyFileName));
            this.key = (SecretKey)in.readObject();
            this.algorithm = key.getAlgorithm();
            in.close();
        }
     
        /**
         * Constructs a new symetric encryptor with the specified key file 
         * containing the secret key.
         * @param keyFile the file containing the secret key.
         * @throws java.io.FileNotFoundException if the file containing the secret
         * key doesn't exist.
         * @throws java.io.IOException if an I/O error occurs during reading the
         * key.
         * @throws java.lang.ClassNotFoundException if the class of the key is
         * unknown.
         */
        public SymetricEncryptor(File keyFile) 
            throws FileNotFoundException, IOException, ClassNotFoundException
        {
            ObjectInputStream in = new ObjectInputStream(new FileInputStream(keyFile));
            this.key = (SecretKey)in.readObject();
            this.algorithm = key.getAlgorithm();
            in.close();
        }
     
        /**
         * Returns the secret key of the underlying symetric encryptor.
         * @return the secret key of the underlying symetric encryptor.
         **/
        public SecretKey getSecretKey()
        {
            return this.key;
        }
     
        /**
         * Returns the algorithm's name of the underlying symetric encryptor.
         * @return the algorithm's name of the underlying symetric encryptor.
         **/
        public String getAlgorithm()
        {
            return this.algorithm;
        }
     
        /**
         * Returns a new instance of SymetricEncryptor generated with the specified
         * algorithm.
         * @param algorithm the algorithm of the symetric encryptor you want to be
         * returned.
         * @return a new instance of SymetricEncryptor generated with the specified
         * algorithm.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         */
        public static SymetricEncryptor getInstance(String algorithm) 
            throws NoSuchAlgorithmException
        {
            return new SymetricEncryptor(generateKey(algorithm));
        }
     
        /**
         * Returns a new instance of SymetricEncryptor generated with the specified
         * algorithm and provider name.
         * @param algorithm the algorithm of the symetric encryptor you want to be
         * returned.
         * @param provider the provider's name of the algorithm of the symetric
         * encryptor you want to be returned.
         * @return a new instance of SymetricEncryptor generated with the specified
         * algorithm.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         * @throws java.security.NoSuchProviderException if the given provider
         * is invalid.
         */
        public static SymetricEncryptor getInstance(String algorithm, String provider) 
            throws NoSuchAlgorithmException, NoSuchProviderException
        {
            return new SymetricEncryptor(generateKey(algorithm, provider));
        }
     
        /**
         * Returns a new instance of SymetricEncryptor generated with the specified
         * algorithm and provider.
         * @param algorithm the algorithm of the symetric encryptor you want to be
         * returned.
         * @param provider the provider of the algorithm of the symetric
         * encryptor you want to be returned.
         * @return a new instance of SymetricEncryptor generated with the specified
         * algorithm.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         */
        public static SymetricEncryptor getInstance(String algorithm, Provider provider) 
            throws NoSuchAlgorithmException
        {
            return new SymetricEncryptor(generateKey(algorithm, provider));
        }
     
        /**
         * Returns a secret key generated with the specified algorithm.
         * @param algorithm the algorithm of the symetric secret key you want to be
         * returned.
         * @return a secret key generated with the specified algorithm.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         */
        public static SecretKey generateKey(String algorithm) 
            throws NoSuchAlgorithmException
        {
            KeyGenerator keygen = KeyGenerator.getInstance(algorithm);
            SecureRandom random = new SecureRandom();
            keygen.init(random);
            SecretKey key = keygen.generateKey();
            return key;
        }
     
        /**
         * Returns a secret key generated with the specified algorithm and provider
         * name.
         * @param algorithm the algorithm of the symetric secret key you want to be
         * returned.
         * @param provider the provider's name of the algorithm of the symetric
         * secret key you want to be returned.
         * @return a secret key generated with the specified algorithm and provider
         * name.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         * @throws java.security.NoSuchProviderException if the given provider
         * is invalid.
         */
        public static SecretKey generateKey(String algorithm, String provider)
            throws NoSuchAlgorithmException, NoSuchProviderException
        {
            KeyGenerator keygen = KeyGenerator.getInstance(algorithm, provider);
            SecureRandom random = new SecureRandom();
            keygen.init(random);
            SecretKey key = keygen.generateKey();
            return key;
        }
     
        /**
         * Returns a secret key generated with the specified algorithm and provider.
         * @param algorithm the algorithm of the symetric secret key you want to be
         * returned.
         * @param provider the provider of the algorithm of the symetric
         * secret key you want to be returned.
         * @return a secret key generated with the specified algorithm and provider.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         */
        public static SecretKey generateKey(String algorithm, Provider provider)
            throws NoSuchAlgorithmException
        {
            KeyGenerator keygen = KeyGenerator.getInstance(algorithm, provider);
            SecureRandom random = new SecureRandom();
            keygen.init(random);
            SecretKey key = keygen.generateKey();
            return key;
        }
     
        /**
         * Writes a secret key generated with the specified algorithm to the 
         * specified output file.
         * @param algorithm the algorithm of the symetric secret key you want to be
         * written.
         * @param outputFileName the name of the file you want the key to be
         * written.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         * @throws java.io.IOException if an I/O error occurs during writing the 
         * key.
         */
        public static void generateAndSaveKey(String algorithm, String outputFileName)
            throws NoSuchAlgorithmException, IOException
        {
            SecretKey key = generateKey(algorithm);
            ObjectOutputStream out = new ObjectOutputStream(
                    new FileOutputStream(outputFileName));
            out.writeObject(key);
            out.close();
        }
     
        /**
         * Writes a secret key generated with the specified algorithm and provider 
         * to the specified output file.
         * @param algorithm the algorithm of the symetric secret key you want to be
         * written.
         * @param provider the provider's name of the algorithm.
         * @param outputFileName the name of the file you want the key to be
         * written.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         * @throws java.security.NoSuchProviderException if the given provider
         * is invalid.
         * @throws java.io.IOException if an I/O error occurs during writing the 
         * key.
         */
        public static void generateAndSaveKey(String algorithm, String provider, 
                String outputFileName)
            throws NoSuchAlgorithmException, NoSuchProviderException, IOException
        {
            SecretKey key = generateKey(algorithm, provider);
            ObjectOutputStream out = new ObjectOutputStream(
                    new FileOutputStream(outputFileName));
            out.writeObject(key);
            out.close();
        }
     
        /**
         * Writes a secret key generated with the specified algorithm and provider 
         * to the specified output file.
         * @param algorithm the algorithm of the symetric secret key you want to be
         * written.
         * @param provider the provider's name of the algorithm.
         * @param outputFileName the name of the file you want the key to be 
         * written.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         * @throws java.io.IOException if an I/O error occurs during writing the 
         * key.
         */
        public static void generateAndSaveKey(String algorithm, Provider provider,
                String outputFileName)
            throws NoSuchAlgorithmException, IOException
        {
            SecretKey key = generateKey(algorithm, provider);
            ObjectOutputStream out = new ObjectOutputStream(
                    new FileOutputStream(outputFileName));
            out.writeObject(key);
            out.close();
        }
     
        /**
         * Writes a secret key generated with the specified algorithm to the 
         * specified output file.
         * @param algorithm the algorithm of the symetric secret key you want to be
         * written.
         * @param outputFile the file you want the key to be written.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         * @throws java.io.IOException if an I/O error occurs during writing the 
         * key.
         */
        public static void generateAndSaveKey(String algorithm, File outputFile)
            throws NoSuchAlgorithmException, IOException
        {
            SecretKey key = generateKey(algorithm);
            ObjectOutputStream out = new ObjectOutputStream(
                    new FileOutputStream(outputFile));
            out.writeObject(key);
            out.close();
        }
     
        /**
         * Writes a secret key generated with the specified algorithm and provider 
         * to the specified output file.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @param algorithm the algorithm of the symetric secret key you want to be
         * written.
         * @param provider the provider's name of the algorithm.
         * @param outputFile the file you want the key to be written.
         * @throws java.security.NoSuchProviderException if the given provider is invalid.
         * @throws java.security.NoSuchAlgorithmException if the given algorithm is invalid.
         * @throws java.io.IOException if an I/O error occurs during writing the 
         * key.
         */
        public static void generateAndSaveKey(String algorithm, String provider, File outputFile)
            throws NoSuchAlgorithmException, NoSuchProviderException, IOException
        {
            SecretKey key = generateKey(algorithm, provider);
            ObjectOutputStream out = new ObjectOutputStream(
                    new FileOutputStream(outputFile));
            out.writeObject(key);
            out.close();
        }
     
        /**
         * Writes a secret key generated with the specified algorithm and provider 
         * to the specified output file.
         * @param algorithm the algorithm of the symetric secret key you want to be
         * written.
         * @param provider the provider's name of the algorithm.
         * @param outputFile the file you want the key to be written.
         * @see org.umh.crypto.SymetricEncryptor#AES
         * @see org.umh.crypto.SymetricEncryptor#DES
         * @see org.umh.crypto.SymetricEncryptor#DES_EDE
         * @see org.umh.crypto.SymetricEncryptor#BLOWFISH
         * @see org.umh.crypto.SymetricEncryptor#RC2
         * @see org.umh.crypto.SymetricEncryptor#ARCFOUR
         * @throws java.security.NoSuchAlgorithmException if the given algorithm
         * is invalid.
         * @throws java.io.IOException if an I/O error occurs during writing the 
         * key.
         */
        public static void generateAndSaveKey(String algorithm, Provider provider, File outputFile)
            throws NoSuchAlgorithmException, IOException
        {
            SecretKey key = generateKey(algorithm, provider);
            ObjectOutputStream out = new ObjectOutputStream(
                    new FileOutputStream(outputFile));
            out.writeObject(key);
            out.close();
        }
     
        /**
         * Encrypts the specified input file to the specified output file with the
         * underlying symetric encryptor.
         * @param inputFileName the name of the file you want to be encrypted.
         * @param outputFileName the name of the file where you want the encrypted
         * datas to be written.
         * @throws FileNotFoundException if the input file doesn't exists.
         * @throws IOException if an I/O error occurs during reading the input file
         * or writting the encrypted datas to the output file.
         * @throws InvalidKeyException if the key of the underlying symetric
         * encryptor is not a valid key for this operation.
         * @throws NoSuchPaddingException if the algorithm contains a padding 
         * scheme that is not available.
         **/
        public void encryptFile(String inputFileName, String outputFileName) 
            throws FileNotFoundException, IOException, InvalidKeyException, 
                NoSuchPaddingException
        {
            InputStream in = new FileInputStream(inputFileName);
            OutputStream out = new FileOutputStream(outputFileName);
            Cipher cipher = null;
            try
            {
                cipher = Cipher.getInstance(algorithm);
            } 
            catch(NoSuchAlgorithmException ex)//never launched
            {
                ex.printStackTrace();
            }
     
            cipher.init(Cipher.ENCRYPT_MODE, key);
     
            super.crypt(in, out, cipher);
            in.close();
            out.close();
        }
     
        /**
         * Encrypts the specified input file to the specified output file with the
         * underlying symetric encryptor.
         * @param inputFile the file you want to be encrypted.
         * @param outputFile the file  where you want the encrypted datas to be 
         * written.
         * @throws FileNotFoundException if the input file doesn't exists.
         * @throws IOException if an I/O error occurs during reading the input file
         * or writting the encrypted datas to the output file.
         * @throws InvalidKeyException if the key of the underlying symetric
         * encryptor is not a valid key for this operation.
         * @throws NoSuchPaddingException if the algorithm contains a padding 
         * scheme that is not available.
         **/
        public void encryptFile(File inputFile, File outputFile)
            throws FileNotFoundException, IOException, InvalidKeyException, 
                NoSuchPaddingException
        {
            InputStream in = new FileInputStream(inputFile);
            OutputStream out = new FileOutputStream(outputFile);
            Cipher cipher = null;
            try
            {
                cipher = Cipher.getInstance(algorithm);
            } 
            catch(NoSuchAlgorithmException ex)//never launched
            {
                ex.printStackTrace();
            }
     
            cipher.init(Cipher.ENCRYPT_MODE, key);
     
            super.crypt(in, out, cipher);
            in.close();
            out.close();
        }
     
        /**
         * Decrypts the specified input file to the specified output file with the
         * underlying symetric encryptor.
         * @param inputFileName the name of the file you want to be decrypted.
         * @param outputFileName the name of the file where you want the decrypted
         * datas to be written.
         * @throws FileNotFoundException if the input file doesn't exists.
         * @throws IOException if an I/O error occurs during reading the input file
         * or writting the decrypted datas to the output file.
         * @throws InvalidKeyException if the key of the underlying symetric
         * encryptor is not a valid key for this operation.
         * @throws NoSuchPaddingException if the algorithm contains a padding 
         * scheme that is not available.
         **/
        public void decryptFile(String inputFileName, String outputFileName)
            throws FileNotFoundException, IOException, InvalidKeyException, 
                NoSuchPaddingException
        {
            InputStream in = new FileInputStream(inputFileName);
            OutputStream out = new FileOutputStream(outputFileName);
            Cipher cipher = null;
            try
            {
                cipher = Cipher.getInstance(algorithm);
            } 
            catch(NoSuchAlgorithmException ex)//never launched
            {
                ex.printStackTrace();
            }
     
            cipher.init(Cipher.DECRYPT_MODE, key);
     
            super.crypt(in, out, cipher);
            in.close();
            out.close();
        }
     
        /**
         * Decrypts the specified input file to the specified output file with the
         * underlying symetric encryptor.
         * @param inputFile the file you want to be decrypted.
         * @param outputFile the file where you want the decrypted datas to be 
         * written.
         * @throws FileNotFoundException if the input file doesn't exists.
         * @throws IOException if an I/O error occurs during reading the input file
         * or writting the decrypted datas to the output file.
         * @throws InvalidKeyException if the key of the underlying symetric
         * encryptor is not a valid key for this operation.
         * @throws NoSuchPaddingException if the algorithm contains a padding 
         * scheme that is not available.
         **/
        public void decryptFile(File inputFile, File outputFile)
            throws FileNotFoundException, IOException, InvalidKeyException, 
                NoSuchPaddingException
        {
            InputStream in = new FileInputStream(inputFile);
            OutputStream out = new FileOutputStream(outputFile);
            Cipher cipher = null;
            try
            {
                cipher = Cipher.getInstance(algorithm);
            } 
            catch(NoSuchAlgorithmException ex)//never launched
            {
                ex.printStackTrace();
            }
     
            cipher.init(Cipher.DECRYPT_MODE, key);
     
            super.crypt(in, out, cipher);
            in.close();
            out.close();
        }
     
        /**
         * Encrypts the specified input stream to the specified output stream with 
         * the underlying symetric encryptor.
         * @param in the input stream you want to be encrypted.
         * @param out the output stream where you want the encrypted datas to be 
         * written.
         * @throws IOException if an I/O error occurs during reading the input stream
         * or writting the decrypted datas to the output stream.
         * @throws InvalidKeyException if the key of the underlying symetric
         * encryptor is not a valid key for this operation.
         * @throws NoSuchPaddingException if the algorithm contains a padding 
         * scheme that is not available.
         **/
        public void encryptStream(InputStream in, OutputStream out)
            throws IOException, InvalidKeyException, NoSuchPaddingException
        {
            Cipher cipher = null;
            try
            {
                cipher = Cipher.getInstance(algorithm);
            } 
            catch(NoSuchAlgorithmException ex)//never launched
            {
                ex.printStackTrace();
            }
     
            cipher.init(Cipher.ENCRYPT_MODE, key);
     
            super.crypt(in, out, cipher);
            in.close();
            out.close();
        }
     
        /**
         * Decrypts the specified input stream to the specified output stream with 
         * the underlying symetric encryptor.
         * @param in the input stream you want to be decrypted.
         * @param out the output stream where you want the decrypted datas to be 
         * written.
         * @throws IOException if an I/O error occurs during reading the input stream
         * or writting the decrypted datas to the output stream.
         * @throws InvalidKeyException if the key of the underlying symetric
         * encryptor is not a valid key for this operation.
         * @throws NoSuchPaddingException if the algorithm contains a padding 
         * scheme that is not available.
         */
        public void decryptStream(InputStream in, OutputStream out)
            throws IOException, InvalidKeyException, NoSuchPaddingException
        {
            Cipher cipher = null;
            try
            {
                cipher = Cipher.getInstance(algorithm);
            } 
            catch(NoSuchAlgorithmException ex)//never launched
            {
                ex.printStackTrace();
            }
     
            cipher.init(Cipher.DECRYPT_MODE, key);
     
            super.crypt(in, out, cipher);
            in.close();
            out.close();
        }
     
    }

    Si tu as des questions n'hésite pas
    Désolé pour le cotretemps dû à maclasse, il faut vraiment que je nettoie toutes les veilles classes postées et que je les remplace par les mises à jour...
    On a toujours besoin d'un plus bourrin que soi

    Oui il y a quelques bugs dans ma librairie de Sécurité, mais les classes postées ne sont pas celles de la dernière version, et j'ai la flemme de tout modifier. Je vous donnerai avec plaisir la dernière version du jar par mp.

  3. #3
    Membre averti Avatar de Razgriz
    Profil pro
    Professeur / chercheur en informatique / mathématiques
    Inscrit en
    Avril 2006
    Messages
    391
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Professeur / chercheur en informatique / mathématiques

    Informations forums :
    Inscription : Avril 2006
    Messages : 391
    Points : 306
    Points
    306
    Par défaut
    Et voici la superclasse indispensable :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
     
    package org.cosmopol.crypto;
     
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.ArrayList;
    import javax.crypto.BadPaddingException;
    import javax.crypto.Cipher;
    import javax.crypto.IllegalBlockSizeException;
    import javax.crypto.ShortBufferException;
     
    /**
     * This class models cipher algorithm encryptors wich are represented by
     * their stream and bytes encryption method.
     * @author Absil Romain
     */
    public class CipherEncryptor
    {
        /**
         * Crypts or decrypts the specified input stream to the specified output
         * stream with a given cipher. The crypting or decrypting operation is 
         * determined by the cipher's state.
         * @param cipher The cipher used to crypt the specified input stream to the specified output
         * stream.
         * @param in the input srteal stream to be encypted or decrypted.
         * @param out the output stream to be encypted or decrypted.
         * @throws java.io.IOException if an I/O error occurs during crypting the input stream to the output stream.
         */
        public void crypt(InputStream in, OutputStream out, Cipher cipher)
            throws IOException
        {
            int blockSize = cipher.getBlockSize();
            int outputSize = cipher.getOutputSize(blockSize);
            byte[] inBytes = new byte[blockSize];
            byte[] outBytes = new byte[outputSize];
     
            int inLength = 0;
            boolean done = false;
            while(!done)
            {
                inLength = in.read(inBytes);
                if(inLength == blockSize)
                {
                    try
                    {
                        int outLength = cipher.update(inBytes, 0, blockSize, outBytes);
                        out.write(outBytes, 0, outLength);
                    }
                    catch(ShortBufferException e)
                    {
                        e.printStackTrace();
                    }
                }
                else
                    done = true;
            }
     
            try
            {
                if(inLength > 0)
                    outBytes = cipher.doFinal(inBytes, 0, inLength);
                else
                    outBytes = cipher.doFinal();
                out.write(outBytes);
            }
            catch(IllegalBlockSizeException e)
            {
                e.printStackTrace();
            }
            catch(BadPaddingException e)
            {
                e.printStackTrace();
            }
        }
     
    }
    On a toujours besoin d'un plus bourrin que soi

    Oui il y a quelques bugs dans ma librairie de Sécurité, mais les classes postées ne sont pas celles de la dernière version, et j'ai la flemme de tout modifier. Je vous donnerai avec plaisir la dernière version du jar par mp.

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 47
    Points : 43
    Points
    43
    Par défaut
    OK merci,
    je vais regarder ça de près ce soir et je te tiens au courant.
    MarsOran.
    au fait, quel algo (AES, DES, BlowFish..etc) me conseilles tu ? c'est pour une application WEB (J2EE) qui stocke des documents (plus ou moins important).

  5. #5
    Membre averti Avatar de Razgriz
    Profil pro
    Professeur / chercheur en informatique / mathématiques
    Inscrit en
    Avril 2006
    Messages
    391
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Professeur / chercheur en informatique / mathématiques

    Informations forums :
    Inscription : Avril 2006
    Messages : 391
    Points : 306
    Points
    306
    Par défaut
    Les puissances des algos sont plus ou moins équivalentes, mais ne prend pas le DES il est considéré à présent comme obsolète, et avec de l'achernement on sait le casser. Non si pas prend l'AES, c'est un standart. Mais bon le stress vient du problème de transmition des clés (voir mes post dans la rubrique contribuez pour plus d'explication). Si tu veux vraiment bien sécuriser prend ma classe qui crypte en RSA (dans la même rubrique).
    On a toujours besoin d'un plus bourrin que soi

    Oui il y a quelques bugs dans ma librairie de Sécurité, mais les classes postées ne sont pas celles de la dernière version, et j'ai la flemme de tout modifier. Je vous donnerai avec plaisir la dernière version du jar par mp.

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 47
    Points : 43
    Points
    43
    Par défaut
    OK, dans ce cas, c'est bon, le programme RSA fonctionne correctement, merci.

    le problème avec ces algos, c'est la clé qu'il faut bien cacher !! car je stocke mon document dans un répertoire (de mon serveur) et la clé (fichier) dans un autre répertoire (avec un nom et une extension un peu dissimulé), le problème, est que si quelqu'un retrouve la clé et sache faire le lien avec le document correspondant (en sachant aussi que c'est RSA) ->il pourra facilement décrypter les docs !! c'est une chance minim que ça arrive mais bon !!
    MarsOran.

  7. #7
    Membre expert
    Avatar de Janitrix
    Inscrit en
    Octobre 2005
    Messages
    3 391
    Détails du profil
    Informations forums :
    Inscription : Octobre 2005
    Messages : 3 391
    Points : 3 401
    Points
    3 401
    Par défaut
    Tu peux (tu dois) crypter la clé privée avec un algorithme comme PBE (Password Based Encryption). Cet algorithme règle le problème de gestion des clés car il utilise une phrase comme mot de passe. Donc, tu donnes un mot de passe à PBD (assez long bien sûr) et il va te crypter le fichier de ta clé privée. Tu pourras récupérer la clé en décryptant avec le mot de passe.

    Tout cela est possible avec Java, car ce dernier gère PBE.

    Fait une petite recherche pour savoir comment il faut faire au niveau du code.

    Bonne chance.

  8. #8
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    47
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 47
    Points : 43
    Points
    43
    Par défaut
    OK, merci.
    Je pense que je vais opté pour ce procédé même si, il faut sauvegarder deux paramètres (le "salt" et "iterations") (je pense que je vais les mettre dans la BD)
    MarsOran.

  9. #9
    Membre averti Avatar de Razgriz
    Profil pro
    Professeur / chercheur en informatique / mathématiques
    Inscrit en
    Avril 2006
    Messages
    391
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Professeur / chercheur en informatique / mathématiques

    Informations forums :
    Inscription : Avril 2006
    Messages : 391
    Points : 306
    Points
    306
    Par défaut
    Le problème de cacher la clé ne se pose pas dans le cas d'un algorithme de clé privée comme le RSA, à la génération tu garde sur toi la clé privée et tu ne la stocke pas. La clé publique tu la donne à qui tu veux, en effet celle-ci ne sert qu'à crypter les documents, et ce n'est pas une opération que tu souhate protéger (en effet on crypte en général un document pour que des tiers ne puissent pas le lire, i.e. ils doivent être incapable de le décrypter).

    Une fois le jeu de clé généré, tu mets la clé publique dans un endroit accéssible à tout le monde, afin que quiconque voulant te remettre des documents ensibles puisse les crypter, empêchant ainsi toute autre personne que toi (même la personne qui la crypté) de le lire. Toi seul possède donc la capacité de décrypter.

    Pour le cryptage avec PBE, je sais pas comment on fait personellement, mais c'est vrai que c'est plus facile de retenir une phrase que deux nombres, même si je considère que même si elle est cryptée, stocker la clé au même endroit que les fichiers représente une faille de sécurité. Plutôt que de demander une authentification avec login, password, et phrase pour décrypter, demande plutôt login, password et fichier contenant la clé privée (à ce moment-là tu insère un périphérique (clé USB,...) contenant la clé et tu lui donnes. Ca marche tout aussi bien, on ne perd pas de temps à crypter / décrypter la clé, et n'importe qui peut aisément comprendre que ce niveau de sécurité est supérieur à un stockage physique sur ton disque de la clé privée, même si elle est cryptée (en effet on a toujours plus de chance de la décrypter si elle est présente sur le disque que si elle ne l'est pas, sans compter que si un quidam furieux de ne pas avoir su lire les fichiers supprime ta clé, tes fichiers sont définivement perdus).

    En résumé, si j'étais toi, je n'utiliserai pas PBE pour crypter la clé privée, je la garderai tout le temps sur moi (ou avec les personnes de confiance ayant l'authorisation de consulter les documnts), sur un support amovible. Quand tu lance ton programme, tu demande un login et un pass, afin de fournir quelques services de base, et chaque fois que le programme a besoin de décrypter, tu demande la clé privée.

    Voilà donc
    On a toujours besoin d'un plus bourrin que soi

    Oui il y a quelques bugs dans ma librairie de Sécurité, mais les classes postées ne sont pas celles de la dernière version, et j'ai la flemme de tout modifier. Je vous donnerai avec plaisir la dernière version du jar par mp.

  10. #10
    Membre à l'essai
    Profil pro
    Intégrateur
    Inscrit en
    Décembre 2008
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Intégrateur
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Décembre 2008
    Messages : 111
    Points : 18
    Points
    18
    Par défaut RSA et documents !
    Je reviens que quelque mots échangé autour du chiffrement de documents, et perso, je déconseille très fortement d'utiliser RSA pour chiffrer des documents car on rencontrera des problèmes de perf lors du déchiffrement, le plus sage serai de chiffrer les documents en AES, puis chiffrer la clé AES en RSA, cela donne nettement des résultats meilleurs allant jusqu'a un rapport de 20 000 entre les deux solutions.

    Si vous avez d'autre proposition, je suis preneur

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Chiffrement de fichier avec AES
    Par Leelith dans le forum Sécurité
    Réponses: 7
    Dernier message: 08/10/2012, 15h40
  2. decrypter un fichier avec GPG
    Par dellys2 dans le forum Programmation système
    Réponses: 1
    Dernier message: 23/02/2012, 15h54
  3. Crypter mots de passe avec AES Encrypt
    Par maxlpn dans le forum Administration
    Réponses: 6
    Dernier message: 25/07/2011, 11h30
  4. [MCRYPT] Est-il possible de crypter des fichiers avec les bibliothèques de hash ?
    Par a028762 dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 01/12/2006, 09h18
  5. Crypter un fichier avec MD5
    Par hammag dans le forum Sécurité
    Réponses: 14
    Dernier message: 29/11/2006, 10h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo