~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to extra/yassl/src/yassl_imp.cpp

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
   Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
 
2
   Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
3
3
 
4
4
   This program is free software; you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
11
11
   GNU General Public License for more details.
12
12
 
13
13
   You should have received a copy of the GNU General Public License
14
 
   along with this program; see the file COPYING. If not, write to the
15
 
   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16
 
   MA  02110-1301  USA.
 
14
   along with this program; if not, write to the Free Software
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
17
16
*/
18
17
 
19
18
/*  yaSSL source implements all SSL.v3 secification structures.
884
883
        else
885
884
            hmac(ssl, verify, data, aSz, alert, true);
886
885
 
887
 
        // read mac and fill
 
886
        // read mac and skip fill
888
887
        int    digestSz = ssl.getCrypto().get_digest().get_digestSize();
889
888
        opaque mac[SHA_LEN];
890
889
        input.read(mac, digestSz);
891
890
 
892
891
        if (ssl.getSecurity().get_parms().cipher_type_ == block) {
893
892
            int    ivExtra = 0;
894
 
        opaque fill;
895
893
 
896
894
            if (ssl.isTLSv1_1())
897
895
                ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
898
896
            int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra -
899
897
                        aSz - digestSz;
900
 
        for (int i = 0; i < padSz; i++) 
901
 
            fill = input[AUTO];
 
898
            input.set_current(input.get_current() + padSz);
902
899
        }
903
900
 
904
901
        // verify
981
978
void Data::Process(input_buffer& input, SSL& ssl)
982
979
{
983
980
    int msgSz = ssl.getSecurity().get_parms().encrypt_size_;
984
 
    int pad   = 0, padByte = 0;
 
981
    int pad   = 0, padSz = 0;
985
982
    int ivExtra = 0;
986
983
 
987
984
    if (ssl.getSecurity().get_parms().cipher_type_ == block) {
988
985
        if (ssl.isTLSv1_1())  // IV
989
986
            ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
990
987
        pad = *(input.get_buffer() + input.get_current() + msgSz -ivExtra - 1);
991
 
        padByte = 1;
 
988
        padSz = 1;
992
989
    }
993
990
    int digestSz = ssl.getCrypto().get_digest().get_digestSize();
994
 
    int dataSz = msgSz - ivExtra - digestSz - pad - padByte;   
 
991
    int dataSz = msgSz - ivExtra - digestSz - pad - padSz;
995
992
    opaque verify[SHA_LEN];
996
993
 
997
994
    const byte* rawData = input.get_buffer() + input.get_current();
1020
1017
            hmac(ssl, verify, rawData, dataSz, application_data, true);
1021
1018
    }
1022
1019
 
1023
 
    // read mac and fill
 
1020
    // read mac and skip fill
1024
1021
    opaque mac[SHA_LEN];
1025
 
    opaque fill;
1026
1022
    input.read(mac, digestSz);
1027
 
    for (int i = 0; i < pad; i++) 
1028
 
        fill = input[AUTO];
1029
 
    if (padByte)
1030
 
        fill = input[AUTO];    
 
1023
    input.set_current(input.get_current() + pad + padSz);
1031
1024
 
1032
1025
    // verify
1033
1026
    if (dataSz) {
2073
2066
        if (ssl.isTLSv1_1())
2074
2067
            ivExtra = ssl.getCrypto().get_cipher().get_blockSize();
2075
2068
 
2076
 
    opaque fill;
2077
2069
    int    padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra -
2078
2070
                     HANDSHAKE_HEADER - finishedSz - digestSz;
2079
 
    for (int i = 0; i < padSz; i++) 
2080
 
        fill = input[AUTO];
 
2071
    input.set_current(input.get_current() + padSz);
2081
2072
 
2082
2073
    // verify mac
2083
2074
    if (memcmp(mac, verifyMAC, digestSz)) {